Changeset 3187


Ignore:
Timestamp:
08/02/03 19:59:18 (18 years ago)
Author:
piso
Message:

getInstance()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/LispCharacter.java

    r2922 r3187  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: LispCharacter.java,v 1.16 2003-07-14 13:21:22 piso Exp $
     5 * $Id: LispCharacter.java,v 1.17 2003-08-02 19:59:18 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2525{
    2626    private final char c;
     27
     28    public static LispCharacter getInstance(char c)
     29    {
     30        try {
     31            LispCharacter character = characters[c];
     32            if (character == null) {
     33                character = characters[c] = new LispCharacter(c);
     34            }
     35            return character;
     36        }
     37        catch (ArrayIndexOutOfBoundsException e) {
     38            return new LispCharacter(c);
     39        }
     40    }
    2741
    2842    public LispCharacter(char c)
     
    152166    }
    153167
     168    private static final LispCharacter[] characters = new LispCharacter[256];
     169
    154170    private static final Primitive1 CHARACTER = new Primitive1("character") {
    155171        public LispObject execute(LispObject arg) throws LispError
Note: See TracChangeset for help on using the changeset viewer.