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>
K Jayatheerth committed
Mar 4, 2026 at 18:35 UTC
b22ed4c4f9667d400744d0ab013745720d91b8d4
1 file changed
+5
-5
path.c
+5
-5
@@ -741,18 +741,18 @@ int calc_shared_perm(struct repository *repo,
741
int mode)
742
{
743
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;
747
else
748
- tweak = repo_settings_get_shared_repository(repo);
748
+ tweak = shared_repo;
749
750
if (!(mode & S_IWUSR))
751
tweak &= ~0222;
752
if (mode & S_IXUSR)
753
/* Copy read bits to execute bits */
754
tweak |= (tweak & 0444) >> 2;
755
- if (repo_settings_get_shared_repository(repo) < 0)
755
+ if (shared_repo < 0)
756
mode = (mode & ~0777) | tweak;
757
else
758
mode |= tweak;