public String addSymbol(char[] buffer,int offset,int len,int hash){
  final int bucket=hash & indexMask;
  String sym=symbols[bucket];
  boolean match=true;
  if (sym != null) {
    if (sym.length() == len) {
      char[] characters=symbols_char[bucket];
      for (int i=0; i < len; i++) {
        if (buffer[offset + i] != characters[i]) {
          match=false;
          break;
        }
      }
      if (match) {
        return sym;
      }
    }
 else {
      match=false;
    }
  }
{
    int entryIndex=0;
    for (Entry entry=buckets[bucket]; entry != null; entry=entry.next) {
      char[] characters=entry.characters;
      if (len == characters.length && hash == entry.hashCode) {
        boolean eq=true;
        for (int i=0; i < len; i++) {
          if (buffer[offset + i] != characters[i]) {
            eq=false;
            break;
          }
        }
        if (!eq) {
          entryIndex++;
          continue;
        }
        return entry.symbol;
      }
    }
    if (entryIndex >= MAX_BUCKET_LENTH) {
      return new String(buffer,offset,len);
    }
  }
  Entry entry=new Entry(buffer,offset,len,hash,buckets[bucket]);
  buckets[bucket]=entry;
  if (match) {
    symbols[bucket]=entry.symbol;
    symbols_char[bucket]=entry.characters;
  }
  return entry.symbol;
}

public String addSymbol ( char [ ] buffer , int offset , int len , int hash ) { final int bucket = hash & indexMask ; String sym = symbols [ bucket ] ; boolean match = true ; if ( sym != null ) { if ( sym . length ( ) == len ) { char [ ] characters = symbols_char [ bucket ] ; for ( int i = 0 ; i < len ; i ++ ) { if ( buffer [ offset + i ] != characters [ i ] ) { match = false ; break ; } } if ( match ) { return sym ; } } else { match = false ; } } { int entryIndex = 0 ; for ( Entry entry = buckets [ bucket ] ; entry != null ; entry = entry . next ) { char [ ] characters = entry . characters ; if ( len == characters . length && hash == entry . hashCode ) { boolean eq = true ; for ( int i = 0 ; i < len ; i ++ ) { if ( buffer [ offset + i ] != characters [ i ] ) { eq = false ; break ; } } if ( ! eq ) { entryIndex ++ ; continue ; } return entry . symbol ; } } if ( entryIndex >= MAX_BUCKET_LENTH ) { return new String ( buffer , offset , len ) ; } } Entry entry = new Entry ( buffer , offset , len , hash , buckets [ bucket ] ) ; buckets [ bucket ] = entry ; if ( match ) { symbols [ bucket ] = entry . symbol ; symbols_char [ bucket ] = entry . characters ; } return entry . symbol ; }
adds the specified symbol to the symbol table and returns a reference to the unique symbol . if the symbol already exists , the previous symbol reference is returned instead , in order guarantee that symbol references remain unique .
