strlen performance implementation

前端 未结 3 1233
别那么骄傲
别那么骄傲 2020-12-16 23:32

This is a multipurpose question:

  • How does this compare to the glibc strlen implementation?
  • Is there a better way to to this in general and for autovec
3条回答
  •  旧时难觅i
    2020-12-16 23:59

    Also, please note this implementation can read past the end of a char array here:

    for (w = (const void *)s; !HASZERO(*w); w++);
    

    and therefore relies on undefined behaviour.

提交回复
热议问题