stariy95 commented on code in PR #627: URL: https://github.com/apache/cayenne/pull/627#discussion_r1965533464
########## cayenne-server/src/main/java/org/apache/cayenne/access/ObjectStore.java: ########## @@ -213,13 +217,28 @@ synchronized ObjectDiff registerDiff(Object nodeId, NodeDiff diff) { return objectDiff; } + private Persistent getUnwrapped(Object nodeId) { + Persistent persistent = objectMap.get(nodeId); + if(persistent == null) { + return null; + } + return ((ObjectStorePersistentWrapper) persistent).dataObject(); + } + /** * Returns a number of objects currently registered with this ObjectStore. * * @since 1.2 */ public int registeredObjectsCount() { - return objectMap.size(); + AtomicInteger counter = new AtomicInteger(); + objectMap.forEach((id, obj) -> { + ObjectStorePersistentWrapper wrapper = (ObjectStorePersistentWrapper) obj; + if(wrapper.hasObject()){ + counter.incrementAndGet(); + } + }); + return counter.get(); Review Comment: In any other place I would go with streams too in a such method. But in the Cayenne core we are trying to keep performance in mind, and leave streams out. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@cayenne.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org