@@ -45,28 +45,27 @@ public final class Index<K extends ABlobLike<?>, V extends ACell> extends AIndex
45
45
*/
46
46
public static final Index <?, ?> EMPTY = Cells .intern (new Index <ABlob , ACell >(0 , null , EMPTY_CHILDREN ,(short ) 0 , 0L ));
47
47
48
- /**
49
- * Child entries, i.e. nodes with keys where this node is a common prefix. Only contains children where mask is set.
50
- * Child entries must have at least one entry.
51
- */
52
- private final Ref <Index <K , V >>[] children ;
53
-
54
48
/**
55
49
* Entry for this node of the radix tree. Invariant assumption that the prefix
56
50
* is correct. May be null if there is no entry at this node.
57
51
*/
58
52
private final MapEntry <K , V > entry ;
59
53
54
+ /**
55
+ * Depth of radix tree entry in number of hex digits.
56
+ */
57
+ private final long depth ;
58
+
60
59
/**
61
60
* Mask of child entries, 16 bits for each hex digit that may be present.
62
61
*/
63
62
private final short mask ;
64
-
63
+
65
64
/**
66
- * Depth of radix tree entry in number of hex digits.
65
+ * Child entries, i.e. nodes with keys where this node is a common prefix. Only contains children where mask is set.
66
+ * Child entries must have at least one entry.
67
67
*/
68
- private final long depth ;
69
-
68
+ private final Ref <Index <K , V >>[] children ;
70
69
71
70
@ SuppressWarnings ({ "rawtypes" , "unchecked" })
72
71
protected Index (long depth , MapEntry <K , V > entry , Ref <Index >[] entries ,
@@ -523,7 +522,7 @@ public int encodeRaw(byte[] bs, int pos) {
523
522
if (count == 1 ) return pos ; // must be a single entry
524
523
525
524
// We only have a meaningful depth if more than one entry
526
- pos = Format . writeVLCCount ( bs , pos , depth ) ;
525
+ bs [ pos ++] = ( byte ) depth ;
527
526
528
527
// finally write children
529
528
pos = Utils .writeShort (bs ,pos ,mask );
@@ -586,13 +585,12 @@ public static <K extends ABlobLike<?>, V extends ACell> Index<K, V> read(Blob b,
586
585
}
587
586
588
587
Index <K ,V > result ;
589
- long depth = Format .readVLCCount (b ,epos );
590
- if (depth < 0 ) throw new BadFormatException ("Negative depth!" );
588
+ int depth = 0xFF & b .byteAt (epos );
591
589
if (depth >=MAX_DEPTH ) {
592
590
if (depth ==MAX_DEPTH ) throw new BadFormatException ("More than one entry and MAX_DEPTH" );
593
591
throw new BadFormatException ("Excessive depth!" );
594
592
}
595
- epos +=Format . getVLCCountLength ( depth ) ;
593
+ epos +=1 ;
596
594
597
595
// Need to include children
598
596
short mask = b .shortAt (epos );
0 commit comments