Ticket #2312: string_intern.patch

File string_intern.patch, 1.3 KB (added by jttt, 17 years ago)
  • src/org/openstreetmap/josm/io/OsmReader.java

     
    141139           */
    142140          private OsmPrimitive current;
    143141          private String generator;
     142          private Map<String, String> keys = new HashMap<String, String>();
    144143//          int n = 0;
    145144
    146145          @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
     
    256255
    257256                    } else if (qName.equals("tag")) {
    258257//                         tagsN++;
    259                          current.put(atts.getValue("k"), atts.getValue("v"));
     258                        String key = atts.getValue("k");
     259                        String internedKey = keys.get(key);
     260                        if (internedKey == null) {
     261                            internedKey = key;
     262                            keys.put(key, key);
     263                        }
     264                         current.put(internedKey, atts.getValue("v"));
    260265                    }
    261266               } catch (NumberFormatException x) {
    262267                    x.printStackTrace(); // SAXException does not chain correctly