Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better StringUtil implementation #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions library/stringUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library StringUtils {
/// @dev Does a byte-by-byte lexicographical comparison of two strings.
/// @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) {
function compare(string _a, string _b) public pure returns (int) {
bytes memory a = bytes(_a);
bytes memory b = bytes(_b);
uint minLength = a.length;
Expand All @@ -21,11 +21,11 @@ library StringUtils {
return 0;
}
/// @dev Compares two strings and returns true iff they are equal.
function equal(string _a, string _b) returns (bool) {
function equal(string _a, string _b) public pure returns (bool) {
return compare(_a, _b) == 0;
}
/// @dev Finds the index of the first occurrence of _needle in _haystack
function indexOf(string _haystack, string _needle) returns (int)
function indexOf(string _haystack, string _needle) public pure returns (int)
{
bytes memory h = bytes(_haystack);
bytes memory n = bytes(_needle);
Expand Down