faster strlen?

后端 未结 8 2305
小鲜肉
小鲜肉 2021-02-20 15:49

Typical strlen() traverse from first character till it finds \\0. This requires you to traverse each and every character. In algorithm sense, its O(N).

8条回答
  •  北海茫月
    2021-02-20 16:05

    Get a Core i7 processor.

    Core i7 comes with the SSE 4.2 instruction set. Intel added four additional vector instructions to speed up strlen and related search tasks.

    Here are some interesting thoughts about the new instructions:

    http://smallcode.weblogs.us/oldblog/2007/11/

提交回复
热议问题