{"thread":{"id":"54659","subject":"[PATCH] Make dir_init inline","startedAt":"2020-11-17T21:51:11Z","lastAt":"2020-11-17T21:51:11Z","messageCount":1,"participants":["Seija K. via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"410167","messageId":"pull.916.git.git.1605649846824.gitgitgadget@gmail.com","threadId":"54659","inReplyTo":null,"subject":"[PATCH] Make dir_init inline","fromName":"Seija K. via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-11-17T21:50:46Z","receivedAt":"2020-11-17T21:51:11Z","isPatch":true,"sender":{"key":"name:Seija K.","avatar":null},"body":"From: Seija K <pi1024e@github.com>\n\ncommit: A void that simply calls another function would be better off as inline.\nPlus, dir_init being originally a memset call makes this change more fitting.\nFinally, even if a stack trace is made, a memset call will be in said trace anyway.\n\nSigned-off-by: Seija K. <pi1024e@github.com>\n---\n    Make dir_init inline\n    \n    commit: A void that simply calls another function would be better off as\n    inline. Plus, dir_init being originally a memset call makes this change\n    more fitting. Finally, even if a stack trace is made, a memset call will\n    be in said trace anyway.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-916%2Fpi1024e%2Fpatch-1-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-916/pi1024e/patch-1-v1\nPull-Request: https://github.com/git/git/pull/916\n\n dir.c | 11 +++--------\n dir.h |  5 ++++-\n 2 files changed, 7 insertions(+), 9 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex ebea5f1f91..c9c890785d 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -54,11 +54,6 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,\n static int resolve_dtype(int dtype, struct index_state *istate,\n \t\t\t const char *path, int len);\n \n-void dir_init(struct dir_struct *dir)\n-{\n-\tmemset(dir, 0, sizeof(*dir));\n-}\n-\n int count_slashes(const char *s)\n {\n \tint cnt = 0;\n@@ -167,14 +162,14 @@ static size_t common_prefix_len(const struct pathspec *pathspec)\n \t\t\tchar c = pathspec->items[n].match[i];\n \t\t\tif (c != pathspec->items[0].match[i])\n \t\t\t\tbreak;\n-\t\t\tif (c == '/')\n-\t\t\t\tlen = i + 1;\n \t\t\ti++;\n+\t\t\tif (c == '/')\n+\t\t\t\tlen = i;\n \t\t}\n \t\tif (n == 0 || len < max) {\n \t\t\tmax = len;\n \t\t\tif (!max)\n-\t\t\t\tbreak;\n+\t\t\t\treturn 0;\n \t\t}\n \t}\n \treturn max;\ndiff --git a/dir.h b/dir.h\nindex a3c40dec51..8da509f42c 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -361,7 +361,10 @@ int match_pathspec(const struct index_state *istate,\n int report_path_error(const char *ps_matched, const struct pathspec *pathspec);\n int within_depth(const char *name, int namelen, int depth, int max_depth);\n \n-void dir_init(struct dir_struct *dir);\n+static inline void dir_init(struct dir_struct *dir)\n+{\n+\tmemset(dir, 0, sizeof(*dir));\n+}\n \n int fill_directory(struct dir_struct *dir,\n \t\t   struct index_state *istate,\n\nbase-commit: e31aba42fb12bdeb0f850829e008e1e3f43af500\n-- \ngitgitgadget\n"}]}