Skip to content

Commit

Permalink
Use cache for base time unit strings
Browse files Browse the repository at this point in the history
Closes gh-4352
  • Loading branch information
izeye committed Dec 10, 2023
1 parent 29e437b commit e81f3d7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,12 @@ protected String getConventionName(Meter.Id id) {
*/
protected abstract DistributionStatisticConfig defaultHistogramConfig();

private final EnumMap<TimeUnit, String> baseTimeUnitStringCache = new EnumMap<>(TimeUnit.class);

private String getBaseTimeUnitStr() {
return getBaseTimeUnit().toString().toLowerCase();
TimeUnit baseTimeUnit = getBaseTimeUnit();
return this.baseTimeUnitStringCache.computeIfAbsent(baseTimeUnit,
(timeUnit) -> timeUnit.toString().toLowerCase());
}

/**
Expand Down

0 comments on commit e81f3d7

Please sign in to comment.