commit f2b16adaedf4891924ea61e7f357b02c6cf42bdf from: Stefan Sperling date: Fri Aug 02 13:50:16 2019 UTC cache path length in struct got_pathlist_entry commit - d572f5860a456fe9ab48d8444dd4cbec28fcae6c commit + f2b16adaedf4891924ea61e7f357b02c6cf42bdf blob - 5356c711e7abf7966e72e3a0a0103d74754fdaf0 blob + f0d43195828bbf72ba276c5aa0ca530acc664943 --- got/got.c +++ got/got.c @@ -1193,7 +1193,7 @@ cmd_update(int argc, char *argv[]) if (branch_name) { struct got_object_id *head_commit_id; TAILQ_FOREACH(pe, &paths, entry) { - if (strlen(pe->path) == 0) + if (pe->path_len == 0) continue; error = got_error_msg(GOT_ERR_BAD_PATH, "switching between branches requires that " blob - 929be76fb48b7a1098cb03f674b1c4ff5f5e08a5 blob + 756faf8e9b273a128bad4efb6aedef83e1d5426c --- include/got_path.h +++ include/got_path.h @@ -63,6 +63,7 @@ int got_path_cmp(const char *, const char *, size_t, s struct got_pathlist_entry { TAILQ_ENTRY(got_pathlist_entry) entry; const char *path; + size_t path_len; void *data; /* data pointer provided to got_pathlist_insert() */ }; TAILQ_HEAD(got_pathlist_head, got_pathlist_entry); blob - 3605ef1847b2bd3c005f0b2f16f925acf2d76f4d blob + ad3315247c0c2b5991c2ed65848a2255a310541e --- lib/path.c +++ lib/path.c @@ -221,6 +221,7 @@ got_pathlist_insert(struct got_pathlist_entry **insert if (new == NULL) return got_error_from_errno("malloc"); new->path = path; + new->path_len = strlen(path); new->data = data; /* @@ -232,8 +233,8 @@ got_pathlist_insert(struct got_pathlist_entry **insert */ pe = TAILQ_LAST(pathlist, got_pathlist_head); while (pe) { - int cmp = got_path_cmp(pe->path, path, - strlen(pe->path), strlen(path)); + int cmp = got_path_cmp(pe->path, new->path, + pe->path_len, new->path_len); if (cmp == 0) { free(new); /* duplicate */ return NULL; @@ -262,6 +263,7 @@ got_pathlist_append(struct got_pathlist_head *pathlist if (new == NULL) return got_error_from_errno("malloc"); new->path = path; + new->path_len = strlen(path); new->data = data; TAILQ_INSERT_TAIL(pathlist, new, entry); return NULL; blob - b23c7b50712196bd076f5de77b17498bae85707b blob + fe6944aad53fa888590f9943509e0d7a8e3dd644 --- lib/worktree.c +++ lib/worktree.c @@ -1849,7 +1849,7 @@ got_worktree_checkout_files(struct got_worktree *workt bbc_arg.base_commit_id = worktree->base_commit_id; bbc_arg.entry_name = tpd->entry_name; bbc_arg.path = pe->path; - bbc_arg.path_len = strlen(pe->path); + bbc_arg.path_len = pe->path_len; bbc_arg.progress_cb = progress_cb; bbc_arg.progress_arg = progress_arg; err = got_fileindex_for_each_entry_safe(fileindex,