Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ id NSObjectFromValue(const Valdi::Value &value) {
return @(value.toBool());
case Valdi::ValueType::Map:
{
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (const auto &it : *value.getMap()) {
const auto &valueMap = *value.getMap();
NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:valueMap.size()];
for (const auto &it : valueMap) {
dictionary[NSStringFromString(it.first)] = NSObjectFromValue(it.second);
}

Expand All @@ -244,7 +245,7 @@ id NSObjectFromValue(const Valdi::Value &value) {
case Valdi::ValueType::TypedObject:
{
const auto &typedObject = *value.getTypedObject();
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:typedObject.getPropertiesSize()];
for (const auto &property: typedObject) {
dictionary[NSStringFromString(property.name)] = NSObjectFromValue(property.value);
}
Expand Down Expand Up @@ -348,6 +349,7 @@ id NSObjectFromValue(const Valdi::Value &value) {

Valdi::Value ValueFromNSDictionary(NSDictionary<NSString *, id> *dict) {
auto map = Valdi::makeShared<Valdi::ValueMap>();
map->reserve(dict.count);
for (NSString *key in dict) {
id value = [dict objectForKey:key];
auto weakValue = ValueFromNSObject(value);
Expand Down
Loading