• Alan Rogers's avatar
    Use immutable collection for Marshalling MList, MSet, and MMap to ObjectiveC · a659825a
    Alan Rogers authored
    A previous solution to this was to simply return a `-copy`'ed version of the mutable collections we had constructed. But that comes with a slight cost.
    
    This diff, makes use of `+[NSArray arrayWithObjects:count:]`, `+[NSSet setWithObjects:count:]` and `+[NSDictionary dictionaryWithObjects:forKeys:count:]` to construct the collections from `std::vector`s of the appropriate ObjC classes.
    
    The only additional allocation we're doing now is of a single (2 for MMap) std::vector. We're also making use of `reserve()` to ensure we're not reallocating as the vectors are populated.
    a659825a
DBConstants.mm 2.03 KB