-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with object with decimal value #1133
Issue with object with decimal value #1133
Conversation
…o-ac/pact-jvm into issue-with-object-with-decimal-value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to merge this and then update the change.
@@ -94,7 +94,7 @@ protected void skipWhitespace() { | |||
} | |||
|
|||
private char[] allocate(char[] buffer, int size) { | |||
char[] newBuffer = new char[Math.max(buffer.length * 2, size)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual change I was trying to do should be:
buffer.length + Math.max(buffer.length, size)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thank you, what's the rationale behind that?
I have mostly looked at it within the context of parsing the decimal numbers, where as long as the buffer is of the proper size everything's fine, and only checked all the tests were still good with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been trying to minimise the number of array allocations and copies for performance reasons. So start with 16 characters, and then double it if we need to extend. That way it should probably only happen once for numbers. But for large strings it will go from the base (128), 256, 512, 1024, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For that case, we have parsed the first part of the number, so size is that number of digits, but there will be more after the .
, so just expand the buffer to the next point as long as that is big enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for expanding on it
See new tests added in
JsonParserSpec
. Most decimal values as values were not being parses correctly.{"1": { "2": 200.25}}
: was working{"1": { "2": 20.25}}
: wasn't working.The method changed by @e-ivaldi is used in a lot of places, so @uglyog could you think of any unwanted effects?