Skip to content

Commit b22ed4c

Browse files
jayatheerthkulkarnigitster
authored andcommitted
path: remove redundant function calls
repo_settings_get_shared_repository() is invoked multiple times in calc_shared_perm(). While the function internally caches the value, repeated calls still add unnecessary noise. Store the result in a local variable and reuse it instead. This makes it explicit that the value is expected to remain constant and avoids repeated calls in the same scope. Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 61d0b79 commit b22ed4c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

path.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,18 +741,18 @@ int calc_shared_perm(struct repository *repo,
741741
int mode)
742742
{
743743
int tweak;
744-
745-
if (repo_settings_get_shared_repository(repo) < 0)
746-
tweak = -repo_settings_get_shared_repository(repo);
744+
int shared_repo = repo_settings_get_shared_repository(repo);
745+
if (shared_repo < 0)
746+
tweak = -shared_repo;
747747
else
748-
tweak = repo_settings_get_shared_repository(repo);
748+
tweak = shared_repo;
749749

750750
if (!(mode & S_IWUSR))
751751
tweak &= ~0222;
752752
if (mode & S_IXUSR)
753753
/* Copy read bits to execute bits */
754754
tweak |= (tweak & 0444) >> 2;
755-
if (repo_settings_get_shared_repository(repo) < 0)
755+
if (shared_repo < 0)
756756
mode = (mode & ~0777) | tweak;
757757
else
758758
mode |= tweak;

0 commit comments

Comments
 (0)