Skip to content

Commit

Permalink
The JDK has a method for this already
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Apr 25, 2024
1 parent 2fff67d commit f5aa4ac
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/main/java/net/sf/json/util/JSONTokener.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,7 @@ public boolean matches(String pattern) {
}

public boolean startsWith(String prefix) {
int prefixLength = prefix.length();
if (length() - this.myIndex < prefixLength) {
return false;
}
String str = this.mySource.substring(this.myIndex, this.myIndex + prefixLength);
return str.startsWith(prefix);
return this.mySource.startsWith(prefix, this.myIndex);
}

/**
Expand Down

0 comments on commit f5aa4ac

Please sign in to comment.