Index: trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java	(revision 8573)
+++ trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java	(revision 8574)
@@ -487,5 +487,5 @@
         }
 
-        final Map<String, String> result = new HashMap<>();
+        final Map<String, String> result = new HashMap<>(Utils.hashMapInitialCapacity(keys.length / 2));
         for (int i = 0; i < keys.length; i += 2) {
             result.put(keys[i], keys[i + 1]);
@@ -654,8 +654,13 @@
     @Override
     public final Collection<String> keySet() {
-        String[] keys = this.keys;
-        if (keys == null)
+        final String[] keys = this.keys;
+        if (keys == null){
             return Collections.emptySet();
-        Set<String> result = new HashSet<>(keys.length / 2);
+        }
+        if (keys.length == 1){
+            return Collections.singleton(keys[0]);
+        }
+
+        final Set<String> result = new HashSet<>(Utils.hashMapInitialCapacity(keys.length / 2));
         for (int i = 0; i < keys.length; i += 2) {
             result.add(keys[i]);
Index: trunk/src/org/openstreetmap/josm/io/OsmReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmReader.java	(revision 8573)
+++ trunk/src/org/openstreetmap/josm/io/OsmReader.java	(revision 8574)
@@ -439,5 +439,5 @@
         String time = parser.getAttributeValue(null, "timestamp");
         if (time != null && !time.isEmpty()) {
-            current.setTimestamp(DateUtils.fromString(time));
+            current.setRawTimestamp((int)(DateUtils.tsFromString(time)/1000));
         }
 
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 8573)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 8574)
@@ -1366,3 +1366,38 @@
         }
     }
+
+    /**
+     * Returns the initial capacity to pass to the HashMap / HashSet constructor
+     * when it is initialized with a known number of entries.
+     * 
+     * When a HashMap is filled with entries, the underlying array is copied over
+     * to a larger one multiple times. To avoid this process when the number of
+     * entries is known in advance, the initial capacity of the array can be
+     * given to the HashMap constructor. This method returns a suitable value
+     * that avoids rehashing but doesn't waste memory.
+     * @param nEntries the number of entries expected
+     * @param loadFactor the load factor
+     * @return the initial capacity for the HashMap constructor
+     */
+    public static int hashMapInitialCapacity(int nEntries, float loadFactor) {
+        return (int) Math.ceil(nEntries / loadFactor);
+    }
+
+    /**
+     * Returns the initial capacity to pass to the HashMap / HashSet constructor
+     * when it is initialized with a known number of entries.
+     * 
+     * When a HashMap is filled with entries, the underlying array is copied over
+     * to a larger one multiple times. To avoid this process when the number of
+     * entries is known in advance, the initial capacity of the array can be
+     * given to the HashMap constructor. This method returns a suitable value
+     * that avoids rehashing but doesn't waste memory.
+     * 
+     * Assumes default load factor (0.75).
+     * @param nEntries the number of entries expected
+     * @return the initial capacity for the HashMap constructor
+     */
+    public static int hashMapInitialCapacity(int nEntries) {
+        return hashMapInitialCapacity(nEntries, 0.75f);
+    }
 }
Index: trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java	(revision 8573)
+++ trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java	(revision 8574)
@@ -66,4 +66,13 @@
      */
     public static synchronized Date fromString(String str) {
+        return new Date(tsFromString(str));
+    }
+
+    /**
+     * Parses XML date quickly, regardless of current locale.
+     * @param str The XML date as string
+     * @return The date in milliseconds since epoch
+     */
+    public static synchronized long tsFromString(String str) {
         // "2007-07-25T09:26:24{Z|{+|-}01:00}"
         if (checkLayout(str, "xxxx-xx-xxTxx:xx:xxZ") ||
@@ -83,8 +92,8 @@
                 int plusHr = parsePart2(str, 20);
                 int mul = str.charAt(19) == '+' ? -3600000 : 3600000;
-                calendar.setTimeInMillis(calendar.getTimeInMillis()+plusHr*mul);
+                return calendar.getTimeInMillis()+plusHr*mul;
             }
 
-            return calendar.getTime();
+            return calendar.getTimeInMillis();
         } else if (checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxxZ") ||
                 checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx") ||
@@ -99,9 +108,9 @@
                 parsePart2(str, 17));
             long millis = parsePart3(str, 20);
-            if (str.length() == 29)
+            if (str.length() == 29){
                 millis += parsePart2(str, 24) * (str.charAt(23) == '+' ? -3600000 : 3600000);
-            calendar.setTimeInMillis(calendar.getTimeInMillis()+millis);
-
-            return calendar.getTime();
+            }
+
+            return calendar.getTimeInMillis() + millis;
         } else {
             // example date format "18-AUG-08 13:33:03"
@@ -109,11 +118,11 @@
             Date d = f.parse(str, new ParsePosition(0));
             if (d != null)
-                return d;
+                return d.getTime();
         }
 
         try {
-            return XML_DATE.newXMLGregorianCalendar(str).toGregorianCalendar().getTime();
+            return XML_DATE.newXMLGregorianCalendar(str).toGregorianCalendar().getTimeInMillis();
         } catch (Exception ex) {
-            return new Date();
+            return System.currentTimeMillis();
         }
     }
