Skip to content

Commit

Permalink
optimize localInstancesOfObjects
Browse files Browse the repository at this point in the history
• check for empty array
• create new array with correct size
  • Loading branch information
darkv committed Feb 13, 2014
1 parent efee486 commit f0bafe5
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ public static <T extends EOEnterpriseObject> NSArray<T> localInstancesOfObjects(
throw new RuntimeException("ERXUtilites: localInstancesOfObjects: Array is null");
if (ec == null)
throw new RuntimeException("ERXUtilites: localInstancesOfObjects: EditingContext is null");
NSMutableArray<T> localEos = new NSMutableArray<T>();
if (eos.isEmpty()) {
return NSArray.emptyArray();
}
NSMutableArray<T> localEos = new NSMutableArray<T>(eos.count());
for (Enumeration<T> e = eos.objectEnumerator(); e.hasMoreElements();) {
localEos.addObject(localInstanceOfObject(ec, e.nextElement()));
}
Expand Down

0 comments on commit f0bafe5

Please sign in to comment.