Changeset 10374


Ignore:
Timestamp:
11/05/05 20:01:04 (16 years ago)
Author:
piso
Message:

private final EqHashTable? ht => public final EqHashTable? slotTable

File:
1 edited

Legend:

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

    r10372 r10374  
    33 *
    44 * Copyright (C) 2003-2005 Peter Graves
    5  * $Id: Layout.java,v 1.23 2005-11-05 19:31:53 piso Exp $
     5 * $Id: Layout.java,v 1.24 2005-11-05 20:01:04 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2424public final class Layout extends LispObject
    2525{
    26     private static final boolean useHashTable = true;
    27 
    2826    public final LispClass lispClass;
     27    public final EqHashTable slotTable;
    2928
    3029    private final LispObject[] slotNames;
    3130    private final LispObject sharedSlots;
    32     private final EqHashTable ht;
    3331
    3432    private boolean invalid;
     
    6058        Debug.assertTrue(i == length);
    6159        this.sharedSlots = sharedSlots;
    62 
    63         if (useHashTable) {
    64             ht = new EqHashTable(slotNames.length, NIL, NIL);
    65             for (i = slotNames.length; i-- > 0;)
    66                 ht.put(slotNames[i], new Fixnum(i));
    67         } else
    68             ht = null;
     60        slotTable = new EqHashTable(slotNames.length, NIL, NIL);
     61        for (i = slotNames.length; i-- > 0;)
     62            slotTable.put(slotNames[i], new Fixnum(i));
    6963    }
    7064
     
    7569        this.slotNames = instanceSlotNames;
    7670        this.sharedSlots = sharedSlots;
    77 
    78         if (useHashTable) {
    79             ht = new EqHashTable(slotNames.length, NIL, NIL);
    80             for (int i = slotNames.length; i-- > 0;)
    81                 ht.put(slotNames[i], new Fixnum(i));
    82         } else
    83             ht = null;
     71        slotTable = new EqHashTable(slotNames.length, NIL, NIL);
     72        for (int i = slotNames.length; i-- > 0;)
     73            slotTable.put(slotNames[i], new Fixnum(i));
    8474    }
    8575
     
    9080        slotNames = oldLayout.slotNames;
    9181        sharedSlots = oldLayout.sharedSlots;
    92 
    93         if (useHashTable) {
    94             ht = new EqHashTable(slotNames.length, NIL, NIL);
    95             for (int i = slotNames.length; i-- > 0;)
    96                 ht.put(slotNames[i], new Fixnum(i));
    97         } else
    98             ht = null;
     82        slotTable = new EqHashTable(slotNames.length, NIL, NIL);
     83        for (int i = slotNames.length; i-- > 0;)
     84            slotTable.put(slotNames[i], new Fixnum(i));
    9985    }
    10086
     
    207193    public int getSlotIndex(LispObject slotName)
    208194    {
    209         if (useHashTable) {
    210             LispObject index = ht.get(slotName);
    211             if (index != null)
    212                 return ((Fixnum)index).value;
    213             return -1;
    214         }
    215         for (int i = slotNames.length; i-- > 0;) {
    216             if (slotNames[i] == slotName)
    217                 return i;
    218         }
     195        LispObject index = slotTable.get(slotName);
     196        if (index != null)
     197            return ((Fixnum)index).value;
    219198        return -1;
    220199    }
Note: See TracChangeset for help on using the changeset viewer.