git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: "Seija K. via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Seija K <pi1024e@github.com>
Subject: [PATCH] Make dir_init inline
Date: Tue, 17 Nov 2020 21:50:46 +0000	[thread overview]
Message-ID: <pull.916.git.git.1605649846824.gitgitgadget@gmail.com> (raw)

From: Seija K <pi1024e@github.com>

commit: A void that simply calls another function would be better off as inline.
Plus, dir_init being originally a memset call makes this change more fitting.
Finally, even if a stack trace is made, a memset call will be in said trace anyway.

Signed-off-by: Seija K. <pi1024e@github.com>
---
    Make dir_init inline
    
    commit: A void that simply calls another function would be better off as
    inline. Plus, dir_init being originally a memset call makes this change
    more fitting. Finally, even if a stack trace is made, a memset call will
    be in said trace anyway.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-916%2Fpi1024e%2Fpatch-1-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-916/pi1024e/patch-1-v1
Pull-Request: https://github.com/git/git/pull/916

 dir.c | 11 +++--------
 dir.h |  5 ++++-
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/dir.c b/dir.c
index ebea5f1f91..c9c890785d 100644
--- a/dir.c
+++ b/dir.c
@@ -54,11 +54,6 @@ static enum path_treatment read_directory_recursive(struct dir_struct *dir,
 static int resolve_dtype(int dtype, struct index_state *istate,
 			 const char *path, int len);
 
-void dir_init(struct dir_struct *dir)
-{
-	memset(dir, 0, sizeof(*dir));
-}
-
 int count_slashes(const char *s)
 {
 	int cnt = 0;
@@ -167,14 +162,14 @@ static size_t common_prefix_len(const struct pathspec *pathspec)
 			char c = pathspec->items[n].match[i];
 			if (c != pathspec->items[0].match[i])
 				break;
-			if (c == '/')
-				len = i + 1;
 			i++;
+			if (c == '/')
+				len = i;
 		}
 		if (n == 0 || len < max) {
 			max = len;
 			if (!max)
-				break;
+				return 0;
 		}
 	}
 	return max;
diff --git a/dir.h b/dir.h
index a3c40dec51..8da509f42c 100644
--- a/dir.h
+++ b/dir.h
@@ -361,7 +361,10 @@ int match_pathspec(const struct index_state *istate,
 int report_path_error(const char *ps_matched, const struct pathspec *pathspec);
 int within_depth(const char *name, int namelen, int depth, int max_depth);
 
-void dir_init(struct dir_struct *dir);
+static inline void dir_init(struct dir_struct *dir)
+{
+	memset(dir, 0, sizeof(*dir));
+}
 
 int fill_directory(struct dir_struct *dir,
 		   struct index_state *istate,

base-commit: e31aba42fb12bdeb0f850829e008e1e3f43af500
-- 
gitgitgadget

                 reply	other threads:[~2020-11-17 21:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.916.git.git.1605649846824.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pi1024e@github.com \
    --subject='Re: [PATCH] Make dir_init inline' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).