Replace NSMutableSet with NSHashTable when Appropriate #trivial (#321)

* Use NSHashTable to avoid needless -hash and -isEqual: calls

* Mark debug-only methods as such for clarity

* Address feedback
This commit is contained in:
Adlai Holler
2017-06-05 16:33:37 -07:00
committed by GitHub
parent 4a97c4e53c
commit a9837f2dc8
13 changed files with 66 additions and 45 deletions

View File

@@ -235,6 +235,20 @@
s; \
})
/**
* Create a new ObjectPointerPersonality NSHashTable by mapping `collection` over `work`, ignoring nil.
*/
#define ASPointerTableByFlatMapping(collection, decl, work) ({ \
NSHashTable *t = [NSHashTable hashTableWithOptions:NSHashTableObjectPointerPersonality]; \
for (decl in collection) {\
id result = work; \
if (result != nil) { \
[t addObject:result]; \
} \
} \
t; \
})
/**
* Create a new array by mapping `collection` over `work`, ignoring nil.
*/