Changeset 529 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2008-01-30T18:02:38+01:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r431 r529 39 39 * The icon cache 40 40 */ 41 private static Map< URL, Image> cache = new HashMap<URL, Image>();41 private static Map<String, Image> cache = new HashMap<String, Image>(); 42 42 43 43 /** … … 75 75 subdir += "/"; 76 76 String ext = name.indexOf('.') != -1 ? "" : ".png"; 77 String full_name = subdir+name+ext; 77 78 78 URL path = getImageUrl(subdir+name+ext); 79 if (path == null) 80 return null; 81 82 Image img = cache.get(path); 79 Image img = cache.get(full_name); 83 80 if (img == null) { 81 // getImageUrl() does a ton of "stat()" calls and gets expensive 82 // and redundant when you have a whole ton of objects. So, 83 // index the cache by the name of the icon we're looking for 84 // and don't bother to create a URL unless we're actually 85 // creating the image. 86 URL path = getImageUrl(full_name); 87 if (path == null) 88 return null; 84 89 img = Toolkit.getDefaultToolkit().createImage(path); 85 cache.put( path, img);90 cache.put(full_name, img); 86 91 } 92 87 93 return new ImageIcon(img); 88 94 }
Note:
See TracChangeset
for help on using the changeset viewer.
