From a31fda24af5c2d78fcaa6509b1aad20d8293d2c0 Mon Sep 17 00:00:00 2001 From: Artem Mylnikov Date: Mon, 25 Nov 2024 23:01:40 +0200 Subject: [PATCH] Don't iterate through runtime classes unnecessarily --- Realm/RLMSchema.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Realm/RLMSchema.mm b/Realm/RLMSchema.mm index aeb72f9579..58d7c8482d 100644 --- a/Realm/RLMSchema.mm +++ b/Realm/RLMSchema.mm @@ -193,8 +193,8 @@ - (void)setObjectSchema:(NSArray *)objectSchema { } - (RLMObjectSchema *)schemaForClassName:(NSString *)className { - if (RLMObjectSchema *schema = _objectSchemaByName[className]) { - return schema; // fast path for already-initialized schemas + if (_objectSchemaByName.count > 0) { + return _objectSchemaByName[className]; // fast path for already-initialized schemas } else if (Class cls = [RLMSchema classForString:className]) { [cls sharedSchema]; // initialize the schema return _objectSchemaByName[className]; // try again