From bf36944971caba994ac5fdf7a3eb95da5d6e3ff6 Mon Sep 17 00:00:00 2001 From: Peter Baumann Date: Wed, 1 Dec 2021 19:42:44 +0100 Subject: [PATCH] Globals: remove unused property StartingRepositorySubDir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The property is set in class GitTfs by calling `git rev-parse --show-prefix` but it is never used. Remove it and also the useless invocation of git rev-parse to improve the overall startup time of git-tfs. For me this leads to a reduction of round about 85 ms in startup time, as can be seen in the measurement with hyperfine. # Version before this change c:\src\git-tfs>hyperfine --warmup=3 -i src\GitTfs\bin\Debug\net472\git-tfs.exe Benchmark 1: src\GitTfs\bin\Debug\net472\git-tfs.exe Time (mean ± s): 825.7 ms ± 15.5 ms [User: 5.4 ms, System: 16.1 ms] Range (min … max): 800.8 ms … 852.0 ms 10 runs Warning: Ignoring non-zero exit code. # Version with this change c:\src\git-tfs>hyperfine --warmup=3 -i src\GitTfs\bin\Debug\net472\git-tfs.exe Benchmark 1: src\GitTfs\bin\Debug\net472\git-tfs.exe Time (mean ± s): 740.9 ms ± 30.8 ms [User: 3.4 ms, System: 23.4 ms] Range (min … max): 695.4 ms … 792.3 ms 10 runs --- src/GitTfs/GitTfs.cs | 9 --------- src/GitTfs/Globals.cs | 2 -- 2 files changed, 11 deletions(-) diff --git a/src/GitTfs/GitTfs.cs b/src/GitTfs/GitTfs.cs index 6f2f08a8..907401cc 100644 --- a/src/GitTfs/GitTfs.cs +++ b/src/GitTfs/GitTfs.cs @@ -111,15 +111,6 @@ namespace GitTfs public void InitializeGlobals() { - var git = _container.GetInstance(); - try - { - _globals.StartingRepositorySubDir = git.CommandOneline("rev-parse", "--show-prefix"); - } - catch (Exception) - { - _globals.StartingRepositorySubDir = ""; - } if (_globals.GitDir != null) { _globals.GitDirSetByUser = true; diff --git a/src/GitTfs/Globals.cs b/src/GitTfs/Globals.cs index 78ac20f8..d0a87e8c 100644 --- a/src/GitTfs/Globals.cs +++ b/src/GitTfs/Globals.cs @@ -96,8 +96,6 @@ namespace GitTfs public bool GitDirSetByUser { get; set; } - public string StartingRepositorySubDir { get; set; } - public IGitRepository Repository { get; set; } public int GcCountdown { get; set; }