public void optimizeFirstBytes ( ) { // now we post process the entries and remove the first byte ones we can optimize for ( MagicEntry entry : entryList ) { byte [ ] startingBytes = entry . getStartsWithByte ( ) ; if ( startingBytes == null || startingBytes . length == 0 ) { continue ; } int index = ( 0xFF & startingBytes [ 0 ] ) ; if ( firstByteEntryLists [ index ] == null ) { firstByteEntryLists [ index ] = new ArrayList < MagicEntry > ( ) ; } firstByteEntryLists [ index ] . add ( entry ) ; /* * We put an entry in the first-byte list but need to leave it in the main list because there may be * optional characters or != or > comparisons in the match */ } }
Optimize the magic entries by removing the first - bytes information into their own lists