-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
书中在sds模块API http://www.redisbook.com/en/latest/internal-datastruct/sds.html
写到
“sdsupdatelen 更新给定 sds 所对应 sdshdr 结构的 free 和 len 算法复杂度 O(1)”
void sdsupdatelen(sds s) {
struct sdshdr *sh = (void*) (s-(sizeof(struct sdshdr)));
// 计算正确的 buf 长度
int reallen = strlen(s);
// 更新属性
sh->free += (sh->len-reallen);
sh->len = reallen;
}
C 函数库 中的 strlen 不是O(n) 么?
Metadata
Metadata
Assignees
Labels
No labels