Skip to content

Commit

Permalink
Improve performance of enhancement providers by only loading once
Browse files Browse the repository at this point in the history
  • Loading branch information
Tara Drwenski committed Jul 23, 2024
1 parent f930ae4 commit c0da0fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cdm/core/src/main/java/ucar/nc2/dataset/VariableDS.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class VariableDS extends Variable implements VariableEnhanced, EnhanceScaleMissingUnsigned {


static final ServiceLoader<EnhancementProvider> ENHANCEMENT_PROVIDERS = ServiceLoader.load(EnhancementProvider.class);

/**
* Constructor when there's no underlying variable.
Expand Down Expand Up @@ -933,7 +933,7 @@ private void createEnhancements() {
this.dataType = scaleOffset != null ? scaleOffset.getScaledOffsetType() : this.dataType;
}
for (Enhance enhance : this.enhanceMode) {
for (EnhancementProvider service : ServiceLoader.load(EnhancementProvider.class)) {
for (EnhancementProvider service : ENHANCEMENT_PROVIDERS) {
if (service.appliesTo(enhance, this.attributes(), dataType)) {
loadedEnhancements.add(service.create(this));
}
Expand Down

0 comments on commit c0da0fe

Please sign in to comment.