Skip to content

Commit

Permalink
remove problematic bigint optimisation (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning authored Apr 10, 2023
1 parent 97b13e6 commit 1fac75c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/main/java/com/fasterxml/jackson/core/io/NumberInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
*/
public final class NumberInput
{
// numbers with more than these characters are better parsed with BigDecimalParser
// parsing numbers with many digits in Java is slower than O(n)

// 04-Apr-2023, tatu: NOTE! This is above default "longest number by chars"
// limit
private final static int LARGE_INT_SIZE = 1250;

/**
* Formerly used constant for a value that was problematic on certain
* pre-1.8 JDKs.
Expand Down Expand Up @@ -496,9 +489,6 @@ public static BigDecimal parseBigDecimal(final char[] ch, final boolean useFastP
* @since v2.14
*/
public static BigInteger parseBigInteger(final String s) throws NumberFormatException {
if (s.length() > LARGE_INT_SIZE) {
return BigDecimalParser.parse(s).toBigInteger();
}
return new BigInteger(s);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

public class BigIntegerParserTest extends com.fasterxml.jackson.core.BaseTest {

public void testFastParseBigIntegerFailsWithENotation() {
String num = "2e308";
try {
BigIntegerParser.parseWithFastParser(num);
fail("expected NumberFormatException");
} catch (NumberFormatException nfe) {
// expected
}
}

public void testLongStringFastParseBigInteger() {
try {
BigIntegerParser.parseWithFastParser(genLongString());
Expand Down

0 comments on commit 1fac75c

Please sign in to comment.