2 ms·
atoi(strchr(s, '-') + 1) What does this do? Finds the first instance of a -, and converts the remainder of a string to an int. 0 allocations, 0 copies. Doing t
by d0mine 14y ago
atoi(strchr(s, '-') + 1)
What does this do? Finds the first instance of a -, and converts the remainder of a string to an int. 0 allocations, 0 copies. Doing this with 0 copies is pretty much impossible in Python, and probably in ruby and Javascript too. </quote>
The copying could be avoided in non-idiomatic Python:
int(buffer(s, s.find("-") + 1))
- ricardobeat 14y ago+s.substr(s.indexOf('-') + 1)