Changeset 8588 in josm


Ignore:
Timestamp:
2015-07-09T23:42:02+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #11657 - User.createOsmUser() memory optimization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/User.java

    r8510 r8588  
    2020 * is only one user object.
    2121 *
    22  *
     22 * @since 227
    2323 */
    2424public final class User {
     
    5959    }
    6060
     61    private static User lastUser = null;
     62
    6163    /**
    6264     * Creates a user known to the OSM server
     
    6769     */
    6870    public static synchronized User createOsmUser(long uid, String name) {
    69         User user = userMap.get(uid);
     71
     72        if (lastUser != null && lastUser.getId() == uid) {
     73            return lastUser;
     74        }
     75
     76        Long ouid = uid;
     77        User user = userMap.get(ouid);
    7078        if (user == null) {
    7179            user = new User(uid, name);
    72             userMap.put(user.getId(), user);
     80            userMap.put(ouid, user);
    7381        }
    7482        if (name != null) user.addName(name);
     83
     84        lastUser = user;
     85
    7586        return user;
    7687    }
Note: See TracChangeset for help on using the changeset viewer.