Skip to content

Commit aa9e358

Browse files
authored
Fixed string equality (#19)
* [fix] fixed string equality * [fix] added `arrayEquals` description
1 parent 320f8db commit aa9e358

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

approximations/src/main/java/generated/java/lang/StringImpl.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,22 @@ public void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) {
292292
}
293293

294294
public static boolean latin1Equals(byte[] value, byte[] other) {
295+
/*
296+
`Engine.arrayEquals` checks arrays lengths:
297+
- if they are equal, but symbolic, returns null
298+
- Otherwise checks equality of each element and returns non-null value
299+
*/
295300
Boolean arrayEquals = Engine.arrayEquals(value, other);
296301
if (arrayEquals != null)
297302
return arrayEquals;
298303

299-
if (value.length == other.length) {
300-
for(int i = 0; i < value.length; ++i) {
301-
if (value[i] != other[i]) {
302-
return false;
303-
}
304+
for(int i = 0; i < value.length; ++i) {
305+
if (value[i] != other[i]) {
306+
return false;
304307
}
305-
306-
return true;
307-
} else {
308-
return false;
309308
}
309+
310+
return true;
310311
}
311312

312313
public boolean equals(Object anObject) {

0 commit comments

Comments
 (0)