Don't use heap-like slot for return in KotlinMutableSet/Dictionary

Fix #3259
This commit is contained in:
Svyatoslav Scherbina
2019-08-30 10:53:49 +03:00
committed by SvyatoslavScherbina
parent 33ab792465
commit 2cb2f6fe03
+12 -4
View File
@@ -366,7 +366,9 @@ static inline id KSet_getElement(KRef set, id object) {
-(instancetype)init {
if (self = [super init]) {
Kotlin_initRuntimeIfNeeded();
Kotlin_MutableSet_createWithCapacity(8, self->setHolder.slotToInit());
ObjHolder holder;
KRef set = Kotlin_MutableSet_createWithCapacity(8, holder.slot());
self->setHolder.init(set);
}
return self;
@@ -375,7 +377,9 @@ static inline id KSet_getElement(KRef set, id object) {
- (instancetype)initWithCapacity:(NSUInteger)numItems {
if (self = [super init]) {
Kotlin_initRuntimeIfNeeded();
Kotlin_MutableSet_createWithCapacity(objCCapacityToKotlin(numItems), self->setHolder.slotToInit());
ObjHolder holder;
KRef set = Kotlin_MutableSet_createWithCapacity(objCCapacityToKotlin(numItems), holder.slot());
self->setHolder.init(set);
}
return self;
@@ -511,7 +515,9 @@ static inline id KMap_get(KRef map, id aKey) {
-(instancetype)init {
if (self = [super init]) {
Kotlin_initRuntimeIfNeeded();
Kotlin_MutableMap_createWithCapacity(8, self->mapHolder.slotToInit());
ObjHolder holder;
KRef map = Kotlin_MutableMap_createWithCapacity(8, holder.slot());
self->mapHolder.init(map);
}
return self;
}
@@ -525,7 +531,9 @@ static inline id KMap_get(KRef map, id aKey) {
- (instancetype)initWithCapacity:(NSUInteger)numItems {
if (self = [super init]) {
Kotlin_initRuntimeIfNeeded();
Kotlin_MutableMap_createWithCapacity(objCCapacityToKotlin(numItems), self->mapHolder.slotToInit());
ObjHolder holder;
KRef map = Kotlin_MutableMap_createWithCapacity(objCCapacityToKotlin(numItems), holder.slot());
self->mapHolder.init(map);
}
return self;
}