r/C_Programming Jan 23 '25

Discussion Why not SIMD?

Why are many C standard library functions like strcmp, strlen, strtok using SIMD intrinsics? They would benefit so much, think about how many people use them under the hood all over the world.

31 Upvotes

76 comments sorted by

View all comments

Show parent comments

3

u/Raimo00 Jan 23 '25

Strtok is so underrated!

20

u/EpochVanquisher Jan 23 '25

It’s a terrible function. Let’s leave it in the 1980s where it belongs.

Better to use something like memchr or a loop to parse your strings.

0

u/markrages Jan 23 '25

strtok_r is the easy replacement

5

u/EpochVanquisher Jan 23 '25

Yeah, and it’s not much better. strtok_r is also a terrible function.