string.h 308 B

12345678910111213
  1. #pragma once
  2. #include "glib.h"
  3. // 计算字符串的长度(经过测试,该版本比采用repne/scasb汇编的运行速度快16.8%左右)
  4. static inline int strlen(const char *s) {
  5. if (s == NULL)
  6. return 0;
  7. register int __res = 0;
  8. while (s[__res] != '\0') {
  9. ++__res;
  10. }
  11. return __res;
  12. }