4 ms·
Dear my... this is way leaner in C. return strrchr(str,',')+1; There are just a handful of branches unless your library goes nuts with vectorization. If
by tropo 8y ago
Dear my... this is way leaner in C.
return strrchr(str,',')+1;
There are just a handful of branches unless your library goes nuts with vectorization.
If you want to handle three forms of broken input:
if(!str)
return NULL;
str = strrchr(str,',');
if(!str)
return NULL;
if(!*++str)
return NULL;
return str;
- db48x 8y agoIt's only leaner in C if you know that the caller doesn't need a freshly-allocated string, and isn't going to free the pointer that you return.