Skip to content

Commit ee18c9b

Browse files
committed
Moving null path computation into static
Moving repeated null path computation into static variable. This change provides a 3% improvement on span creation benchmarks.
1 parent 523df01 commit ee18c9b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal-api/src/main/java/datadog/trace/api/git/GitInfoProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class GitInfoProvider {
2323
INSTANCE = new GitInfoProvider();
2424
INSTANCE.registerGitInfoBuilder(new UserSuppliedGitInfoBuilder());
2525
}
26+
27+
static final String NULL_PATH_STRING = Paths.get("").toAbsolutePath().toString();
2628

2729
private volatile Collection<GitInfoBuilder> builders = Collections.emptyList();
2830

@@ -42,7 +44,7 @@ public GitInfo getGitInfo() {
4244

4345
public GitInfo getGitInfo(@Nullable String repositoryPath) {
4446
if (repositoryPath == null) {
45-
repositoryPath = Paths.get("").toAbsolutePath().toString();
47+
repositoryPath = NULL_PATH_STRING;
4648
}
4749
return gitInfoCache.computeIfAbsent(repositoryPath, this::buildGitInfo);
4850
}

0 commit comments

Comments
 (0)