@@ -291,6 +291,18 @@ private Feature(boolean defaultState) {
291
291
*/
292
292
protected int _quad1 , _quad2 , _quad3 ;
293
293
294
+ /**
295
+ * Marker flag to indicate that standard symbol handling is used
296
+ * (one with symbol table assisted canonicalization. May be disabled
297
+ * in which case alternate stream-line, non-canonicalizing handling
298
+ * is used: usually due to set of symbols
299
+ * (Object property names) is unbounded and will not benefit from
300
+ * canonicalization attempts.
301
+ *
302
+ * @since 2.13
303
+ */
304
+ protected final boolean _symbolsCanonical ;
305
+
294
306
/*
295
307
/**********************************************************
296
308
/* Constants and fields of former 'JsonNumericParserBase'
@@ -355,6 +367,7 @@ public CBORParser(IOContext ctxt, int parserFeatures, int cborFeatures,
355
367
_ioContext = ctxt ;
356
368
_objectCodec = codec ;
357
369
_symbols = sym ;
370
+ _symbolsCanonical = sym .isCanonicalizing ();
358
371
359
372
_inputStream = in ;
360
373
_inputBuffer = inputBuffer ;
@@ -1231,12 +1244,16 @@ public String nextFieldName() throws IOException
1231
1244
if ((_inputEnd - _inputPtr ) < lenMarker ) {
1232
1245
_loadToHaveAtLeast (lenMarker );
1233
1246
}
1234
- name = _findDecodedFromSymbols (lenMarker );
1235
- if (name != null ) {
1236
- _inputPtr += lenMarker ;
1247
+ if (_symbolsCanonical ) {
1248
+ name = _findDecodedFromSymbols (lenMarker );
1249
+ if (name != null ) {
1250
+ _inputPtr += lenMarker ;
1251
+ } else {
1252
+ name = _decodeContiguousName (lenMarker );
1253
+ name = _addDecodedToSymbols (lenMarker , name );
1254
+ }
1237
1255
} else {
1238
1256
name = _decodeContiguousName (lenMarker );
1239
- name = _addDecodedToSymbols (lenMarker , name );
1240
1257
}
1241
1258
}
1242
1259
} else {
@@ -2614,12 +2631,16 @@ protected final JsonToken _decodePropertyName() throws IOException
2614
2631
if ((_inputEnd - _inputPtr ) < lenMarker ) {
2615
2632
_loadToHaveAtLeast (lenMarker );
2616
2633
}
2617
- name = _findDecodedFromSymbols (lenMarker );
2618
- if (name != null ) {
2619
- _inputPtr += lenMarker ;
2634
+ if (_symbolsCanonical ) {
2635
+ name = _findDecodedFromSymbols (lenMarker );
2636
+ if (name != null ) {
2637
+ _inputPtr += lenMarker ;
2638
+ } else {
2639
+ name = _decodeContiguousName (lenMarker );
2640
+ name = _addDecodedToSymbols (lenMarker , name );
2641
+ }
2620
2642
} else {
2621
2643
name = _decodeContiguousName (lenMarker );
2622
- name = _addDecodedToSymbols (lenMarker , name );
2623
2644
}
2624
2645
}
2625
2646
} else {
@@ -2722,15 +2743,18 @@ private final String _decodeLongerName(int len) throws IOException
2722
2743
}
2723
2744
_loadToHaveAtLeast (len );
2724
2745
}
2725
- String name = _findDecodedFromSymbols (len );
2726
- if (name != null ) {
2727
- _inputPtr += len ;
2728
- return name ;
2746
+ if (_symbolsCanonical ) {
2747
+ String name = _findDecodedFromSymbols (len );
2748
+ if (name != null ) {
2749
+ _inputPtr += len ;
2750
+ return name ;
2751
+ }
2752
+ name = _decodeContiguousName (len );
2753
+ return _addDecodedToSymbols (len , name );
2729
2754
}
2730
- name = _decodeContiguousName (len );
2731
- return _addDecodedToSymbols (len , name );
2755
+ return _decodeContiguousName (len );
2732
2756
}
2733
-
2757
+
2734
2758
private final String _decodeChunkedName () throws IOException
2735
2759
{
2736
2760
_finishChunkedText ();
0 commit comments