Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
Corrected whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth committed Sep 11, 2015
1 parent bc65acd commit f0263cd
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions library/stringUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ library StringUtils {
/// @return a negative number if `_a` is smaller, zero if they are equal
/// and a positive numbe if `_b` is smaller.
function compare(string _a, string _b) returns (int) {
bytes memory a = bytes(_a);
bytes memory b = bytes(_b);
uint minLength = a.length;
if (b.length < minLength) minLength = b.length;
//@todo unroll the loop into increments of 32 and do full 32 byte comparisons
for (uint i = 0; i < minLength; i ++)
if (a[i] < b[i])
return -1;
else if (a[i] > b[i])
return 1;
if (a.length < b.length)
return -1;
else if (a.length > b.length)
return 1;
else
return 0;
}
/// @dev Compares two strings and returns true iff they are equal.
function equal(string _a, string _b) returns (bool) {
return compare(_a, _b) == 0;
}
bytes memory a = bytes(_a);
bytes memory b = bytes(_b);
uint minLength = a.length;
if (b.length < minLength) minLength = b.length;
//@todo unroll the loop into increments of 32 and do full 32 byte comparisons
for (uint i = 0; i < minLength; i ++)
if (a[i] < b[i])
return -1;
else if (a[i] > b[i])
return 1;
if (a.length < b.length)
return -1;
else if (a.length > b.length)
return 1;
else
return 0;
}
/// @dev Compares two strings and returns true iff they are equal.
function equal(string _a, string _b) returns (bool) {
return compare(_a, _b) == 0;
}
}

0 comments on commit f0263cd

Please sign in to comment.