Ticket #11657: createUser.patch

File createUser.patch, 1.1 KB (added by shinigami, 9 years ago)

create osm user optimization

  • src/org/openstreetmap/josm/data/osm/User.java

    ### Eclipse Workspace Patch 1.0
    #P JOSM
     
    5858        return user;
    5959    }
    6060
     61
     62    private static User lastUser = null;
     63
    6164    /**
    6265     * Creates a user known to the OSM server
    6366     *
     
    6669     * @return a new OSM user with the given name and uid
    6770     */
    6871    public static synchronized User createOsmUser(long uid, String name) {
    69         User user = userMap.get(uid);
     72
     73        if (lastUser != null && lastUser.getId() == uid){
     74            return lastUser;
     75        }
     76
     77        Long ouid = uid;
     78        User user = userMap.get(ouid);
    7079        if (user == null) {
    7180            user = new User(uid, name);
    72             userMap.put(user.getId(), user);
     81            userMap.put(ouid, user);
    7382        }
    7483        if (name != null) user.addName(name);
     84
     85        lastUser = user;
     86
    7587        return user;
    7688    }
    7789