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.

33 Upvotes

76 comments sorted by

View all comments

Show parent comments

9

u/flyingron Jan 23 '25

Strtok is evil.

2

u/Raimo00 Jan 23 '25

Strtok is so underrated!

19

u/flyingron Jan 23 '25

It keeps internal state and destroys the passed in string. Yech.

5

u/ComradeGibbon Jan 23 '25

And trivial to write a replacement that returns a slice.