Skip to content

Commit a7b3533

Browse files
committed
Speed up bootstrap __build_class__ a little bit
Since we're iterating over the layouts table one by one, and the layouts table will always be at least LayoutId::kLastBuiltinId layouts long, use `Runtime::layoutAt` instead of `Runtime::layoutAtSafe`, which does a bunch of checks. This search is still linear and kind of long, though.
1 parent bab4f77 commit a7b3533

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

runtime/type-builtins.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ RawObject findBuiltinTypeWithName(Thread* thread, const Object& name) {
8282
Object layout(&scope, NoneType::object());
8383
Object type_obj(&scope, NoneType::object());
8484
for (int i = 0; i <= static_cast<int>(LayoutId::kLastBuiltinId); i++) {
85-
layout = runtime->layoutAtSafe(static_cast<LayoutId>(i));
86-
if (layout.isErrorNotFound()) continue;
85+
layout = runtime->layoutAt(static_cast<LayoutId>(i));
86+
if (layout == SmallInt::fromWord(0)) {
87+
// Indicates an invalid LayoutId.
88+
continue;
89+
}
8790
type_obj = Layout::cast(*layout).describedType();
8891
if (!type_obj.isType()) continue;
8992
if (Type::cast(*type_obj).name() == name) {

0 commit comments

Comments
 (0)