You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Framework version: v11 Description: In function Compare::cmp_bytes(), the loop variables i1and i2 are redundant. Code Location: sources/Compare.move, line 57
public fun cmp_bytes(v1: &vector<u8>, v2: &vector<u8>): u8 {
let l1 = Vector::length(v1);
let l2 = Vector::length(v2);
let len_cmp = cmp_u64(l1, l2);
let i1 = 0;
let i2 = 0;
while (i1 < l1 && i2 < l2) {
let elem_cmp = cmp_u8(*Vector::borrow(v1, i1), *Vector::borrow(v2, i2));
if (elem_cmp != 0) {
return elem_cmp
};
// else, compare next element
i1 = i1 + 1;
i2 = i2 + 1;
};
// all compared elements equal; use length comparison to break the tie
len_cmp
}
Recommendation: Remove i2, and change *Vector::borrow(v2, i2) to *Vector::borrow(v2, i1). Also the comparison (elem_cmp != 0) can be changed to (elem_cmp != EQUAL) for clarity.
The text was updated successfully, but these errors were encountered:
Framework version: v11
Description: In function Compare::cmp_bytes(), the loop variables i1and i2 are redundant.
Code Location: sources/Compare.move, line 57
Recommendation: Remove i2, and change *Vector::borrow(v2, i2) to *Vector::borrow(v2, i1). Also the comparison (elem_cmp != 0) can be changed to (elem_cmp != EQUAL) for clarity.
The text was updated successfully, but these errors were encountered: