Changeset 15903 in josm


Ignore:
Timestamp:
2020-02-22T19:40:27+01:00 (4 years ago)
Author:
simon04
Message:

Projections.getProjectionByCode: use Map.computeIfAbsent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r15902 r15903  
    8585    private static final Set<String> allCodes = new HashSet<>();
    8686    private static final Map<String, Supplier<Projection>> projectionSuppliersByCode = new HashMap<>();
    87     private static final Map<String, Projection> projectionsByCode_cache = new HashMap<>();
     87    private static final Map<String, Projection> projectionsByCodeCache = new HashMap<>();
    8888
    8989    /*********************************
     
    361361     */
    362362    public static Projection getProjectionByCode(String code) {
    363         Projection proj = projectionsByCode_cache.get(code);
    364         if (proj != null) return proj;
    365 
     363        return projectionsByCodeCache.computeIfAbsent(code, Projections::computeProjectionByCode);
     364    }
     365
     366    private static Projection computeProjectionByCode(String code) {
     367        Projection proj = null;
    366368        ProjectionDefinition pd = inits.get(code);
    367369        if (pd != null) {
     
    380382            }
    381383        }
    382         if (proj != null) {
    383             projectionsByCode_cache.put(code, proj);
    384         }
    385384        return proj;
    386385    }
Note: See TracChangeset for help on using the changeset viewer.