Changeset 2455 in josm for trunk/src


Ignore:
Timestamp:
2009-11-15T11:04:06+01:00 (15 years ago)
Author:
jttt
Message:

Do not create new instance of User for every OsmPrimitive, share instances for the same user

File:
1 edited

Legend:

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

    r2284 r2455  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.data.osm;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.util.ArrayList;
     
    4850     */
    4951    public static User  createOsmUser(long uid, String name) {
    50         User user = new User(uid, name);
    51         userMap.put(user.getId(), user);
     52        User user = userMap.get(uid);
     53        if (user == null) {
     54            user = new User(uid, name);
     55            userMap.put(user.getId(), user);
     56        }
     57        if (!user.getName().equals(name))
     58            throw new DataIntegrityProblemException(tr("User with the same uid but different name found"));
    5259        return user;
    5360    }
Note: See TracChangeset for help on using the changeset viewer.