Skip to content

Commit 7e026d8

Browse files
committed
Remove unused code
1 parent fb70447 commit 7e026d8

File tree

8 files changed

+0
-702
lines changed

8 files changed

+0
-702
lines changed

impl/core/src/main/java/com/github/skjolber/jsonfilter/core/util/ByteArrayRangesFilter.java

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -682,88 +682,6 @@ public static int skipObjectMaxStringLength(byte[] chars, int offset, int maxStr
682682
}
683683
}
684684

685-
public static int skipArrayMaxStringLength(byte[] chars, int offset, int maxStringLength, ByteArrayRangesFilter filter) {
686-
int level = 1;
687-
688-
while(true) {
689-
switch(chars[offset]) {
690-
case '[' : {
691-
level++;
692-
break;
693-
}
694-
case ']' : {
695-
level--;
696-
697-
if(level == 0) {
698-
return offset + 1;
699-
}
700-
break;
701-
}
702-
case '"' : {
703-
int nextOffset = scanBeyondQuotedValue(chars, offset);
704-
705-
if(nextOffset - offset > maxStringLength) {
706-
// is this a field name or a value? A field name must be followed by a colon
707-
708-
// special case: no whitespace
709-
if(chars[nextOffset] == ':') {
710-
// key
711-
offset = nextOffset + 1;
712-
713-
continue;
714-
} else {
715-
// most likely there is now no whitespace, but a comma, end array or end object
716-
717-
// legal whitespaces are:
718-
// space: 0x20
719-
// tab: 0x09
720-
// carriage return: 0x0D
721-
// newline: 0x0A
722-
723-
if(chars[nextOffset] > 0x20) {
724-
// was a value
725-
filter.addMaxLength(chars, offset + maxStringLength - 1, nextOffset - 1, -(offset + maxStringLength - nextOffset));
726-
} else {
727-
// fast-forward over whitespace
728-
// optimization: scan for highest value
729-
730-
int end = nextOffset;
731-
do {
732-
nextOffset++;
733-
} while(chars[nextOffset] <= 0x20);
734-
735-
if(chars[nextOffset] == ':') {
736-
// was a key
737-
offset = nextOffset + 1;
738-
739-
continue;
740-
} else {
741-
// value
742-
filter.addMaxLength(chars, offset + maxStringLength - 1, end - 1, -(offset + maxStringLength - end));
743-
}
744-
}
745-
}
746-
}
747-
offset = nextOffset;
748-
749-
continue;
750-
}
751-
case 't':
752-
case 'n': {
753-
offset += 4;
754-
continue;
755-
}
756-
case 'f': {
757-
offset += 5;
758-
continue;
759-
}
760-
default :
761-
}
762-
offset++;
763-
}
764-
}
765-
766-
767685
public int getAnonymizeMessageLength() {
768686
return anonymizeMessage.length;
769687
}

impl/core/src/main/java/com/github/skjolber/jsonfilter/core/util/ByteArrayRangesSizeFilter.java

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -70,70 +70,6 @@ public void filter(final byte[] chars, int offset, int length, final ResizableBy
7070
closeStructure(buffer);
7171
}
7272

73-
public int skipObjectOrArrayMaxSize(byte[] chars, int offset, int maxSizeLimit) {
74-
int levelLimit = getLevel() - 1;
75-
76-
int level = getLevel();
77-
78-
boolean[] squareBrackets = getSquareBrackets();
79-
int mark = getMark();
80-
81-
loop:
82-
while(offset < maxSizeLimit) {
83-
84-
switch(chars[offset]) {
85-
case '{' :
86-
case '[' :
87-
{
88-
maxSizeLimit--;
89-
if(offset >= maxSizeLimit) {
90-
break loop;
91-
}
92-
93-
squareBrackets[level] = chars[offset] == '[';
94-
95-
level++;
96-
if(level >= squareBrackets.length) {
97-
squareBrackets = grow(squareBrackets);
98-
}
99-
100-
offset++;
101-
mark = offset;
102-
103-
continue;
104-
}
105-
case ']' :
106-
case '}' : {
107-
level--;
108-
maxSizeLimit++;
109-
110-
offset++;
111-
mark = offset;
112-
113-
if(level == levelLimit) {
114-
break loop;
115-
}
116-
continue;
117-
}
118-
case ',' :
119-
mark = offset;
120-
break;
121-
case '"' : {
122-
offset = scanBeyondQuotedValue(chars, offset);
123-
continue;
124-
}
125-
default : // do nothing
126-
}
127-
offset++;
128-
}
129-
130-
setLevel(level);
131-
setMark(mark);
132-
setMaxSizeLimit(maxSizeLimit);
133-
134-
return offset;
135-
}
136-
13773
public int skipObjectOrArrayMaxSizeMaxStringLength(byte[] chars, int offset, int maxSizeLimit, int maxReadLimit, int maxStringLength) {
13874
int level = getLevel();
13975
int levelLimit = level - 1;

impl/core/src/main/java/com/github/skjolber/jsonfilter/core/util/ByteArrayWhitespaceFilter.java

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -284,120 +284,6 @@ public int skipObjectMaxStringLength(byte[] chars, int offset, int maxStringLeng
284284

285285
}
286286

287-
public int skipArrayMaxStringLength(byte[] chars, int offset, int maxStringLength, ResizableByteArrayOutputStream output, JsonFilterMetrics metrics) {
288-
int level = 1;
289-
290-
int flushOffset = getFlushOffset();
291-
292-
loop: while(true) {
293-
byte c = chars[offset];
294-
if(c <= 0x20) {
295-
// skip this char and any other whitespace
296-
output.write(chars, flushOffset, offset - flushOffset);
297-
do {
298-
offset++;
299-
} while(chars[offset] <= 0x20);
300-
301-
flushOffset = offset;
302-
c = chars[offset];
303-
}
304-
305-
switch(c) {
306-
case '"': {
307-
int nextOffset = ByteArrayRangesFilter.scanQuotedValue(chars, offset);
308-
309-
int endQuoteIndex = nextOffset;
310-
311-
// key or value, might be followed by whitespace
312-
nextOffset++;
313-
314-
if(chars[nextOffset] != ':') {
315-
316-
if(chars[nextOffset] <= 0x20) {
317-
do {
318-
nextOffset++;
319-
} while(chars[nextOffset] <= 0x20);
320-
321-
if(chars[nextOffset] == ':') {
322-
// whitespace before colon
323-
output.write(chars, flushOffset, endQuoteIndex - flushOffset + 1);
324-
output.write(':');
325-
326-
nextOffset++;
327-
328-
if(chars[nextOffset] <= 0x20) {
329-
// whitespace before and after colon
330-
do {
331-
nextOffset++;
332-
} while(chars[nextOffset] <= 0x20);
333-
} else {
334-
// whitespace before colon, but not after
335-
}
336-
337-
flushOffset = nextOffset;
338-
offset = nextOffset;
339-
continue;
340-
}
341-
}
342-
343-
// was a value
344-
if(endQuoteIndex - offset >= maxStringLength) {
345-
ByteArrayWhitespaceFilter.addMaxLength(chars, offset, output, flushOffset, endQuoteIndex, truncateMessage, maxStringLength, digit, metrics);
346-
347-
flushOffset = nextOffset;
348-
}
349-
350-
offset = nextOffset;
351-
352-
continue;
353-
} else {
354-
// was a key
355-
nextOffset++;
356-
357-
if(chars[nextOffset] > 0x20) {
358-
// no whitespace before or after colon
359-
360-
offset = nextOffset;
361-
continue;
362-
}
363-
364-
// whitespace after colon, but not before
365-
output.write(chars, flushOffset, endQuoteIndex - flushOffset + 1);
366-
output.write(':');
367-
368-
do {
369-
nextOffset++;
370-
} while(chars[nextOffset] <= 0x20);
371-
372-
flushOffset = nextOffset;
373-
offset = nextOffset;
374-
}
375-
continue;
376-
}
377-
case '[' :
378-
level++;
379-
380-
break;
381-
case ']' :
382-
level--;
383-
384-
if(level == 0) {
385-
offset++;
386-
break loop;
387-
}
388-
break;
389-
}
390-
offset++;
391-
}
392-
393-
output.write(chars, flushOffset, offset - flushOffset);
394-
395-
setFlushOffset(offset);
396-
397-
return offset;
398-
399-
}
400-
401287
public static int addMaxLength(final byte[] chars, int offset, final ResizableByteArrayOutputStream output, int flushOffset, int endQuoteIndex, byte[] truncateStringValueAsBytes, int maxStringLength, byte[] digit, JsonFilterMetrics metrics) {
402288
// was a value
403289
int aligned = ByteArrayRangesFilter.getStringAlignment(chars, offset + maxStringLength + 1);

impl/core/src/main/java/com/github/skjolber/jsonfilter/core/util/ByteArrayWhitespaceSizeFilter.java

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -64,97 +64,6 @@ public byte[] getTruncateString() {
6464
return truncateMessage;
6565
}
6666

67-
public int skipObjectOrArrayMaxSize(final byte[] chars, int offset, int maxReadLimit, final ResizableByteArrayOutputStream buffer) {
68-
int bracketLevel = getLevel();
69-
int levelLimit = bracketLevel - 1;
70-
71-
int maxSizeLimit = getLimit();
72-
73-
boolean[] squareBrackets = getSquareBrackets();
74-
75-
int mark = getMark();
76-
int writtenMark = getWrittenMark();
77-
78-
int flushOffset = getFlushOffset();
79-
80-
loop: while(offset < maxSizeLimit) {
81-
byte c = chars[offset];
82-
if(c <= 0x20) {
83-
if(flushOffset <= mark) {
84-
writtenMark = buffer.size() + mark - flushOffset;
85-
}
86-
// skip this char and any other whitespace
87-
buffer.write(chars, flushOffset, offset - flushOffset);
88-
do {
89-
offset++;
90-
maxSizeLimit++;
91-
} while(chars[offset] <= 0x20);
92-
93-
if(maxSizeLimit >= maxReadLimit) {
94-
maxSizeLimit = maxReadLimit;
95-
}
96-
97-
flushOffset = offset;
98-
c = chars[offset];
99-
}
100-
101-
switch(c) {
102-
case '{' :
103-
case '[' :
104-
// check corner case
105-
maxSizeLimit--;
106-
if(offset >= maxSizeLimit) {
107-
break loop;
108-
}
109-
110-
squareBrackets[bracketLevel] = c == '[';
111-
112-
bracketLevel++;
113-
if(bracketLevel >= squareBrackets.length) {
114-
boolean[] next = new boolean[squareBrackets.length + 32];
115-
System.arraycopy(squareBrackets, 0, next, 0, squareBrackets.length);
116-
squareBrackets = next;
117-
}
118-
119-
offset++;
120-
mark = offset;
121-
122-
continue;
123-
case '}' :
124-
case ']' :
125-
bracketLevel--;
126-
maxSizeLimit++;
127-
if(maxSizeLimit >= maxReadLimit) {
128-
maxSizeLimit = maxReadLimit;
129-
}
130-
131-
offset++;
132-
mark = offset;
133-
134-
if(bracketLevel == levelLimit) {
135-
break loop;
136-
}
137-
138-
continue;
139-
case ',' :
140-
mark = offset;
141-
break;
142-
case '"':
143-
offset = ByteArrayRangesFilter.scanBeyondQuotedValue(chars, offset);
144-
continue;
145-
}
146-
offset++;
147-
}
148-
149-
setWrittenMark(writtenMark);
150-
setFlushOffset(flushOffset);
151-
setMark(mark);
152-
setLevel(bracketLevel);
153-
setLimit(maxSizeLimit);
154-
155-
return offset;
156-
}
157-
15867
public int skipObjectOrArrayMaxSizeMaxStringLength(final byte[] chars, int offset, int maxReadLimit, final ResizableByteArrayOutputStream buffer, int maxStringLength, JsonFilterMetrics metrics) {
15968

16069
int bracketLevel = getLevel();

0 commit comments

Comments
 (0)