Merge pull request #274 from ponder-lab/upstream_master2

Fix Atom.startsWith() failure case.
This commit is contained in:
Julian Dolby 2017-12-20 22:45:18 +00:00 committed by GitHub
commit a19507312a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -173,6 +173,11 @@ public final class Atom implements Serializable {
public final boolean startsWith(Atom start) {
assert (start != null);
// can't start with something that's longer.
if (val.length < start.val.length)
return false;
// otherwise, we know that this length is greater than or equal to the length of start.
for (int i = 0; i < start.val.length; ++i) {
if (val[i] != start.val[i])
return false;