Skip to content

Commit

Permalink
Speed up bootstrap __build_class__ a little bit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tekknolagi committed Mar 23, 2023
1 parent bab4f77 commit a7b3533
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions runtime/type-builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ RawObject findBuiltinTypeWithName(Thread* thread, const Object& name) {
Object layout(&scope, NoneType::object());
Object type_obj(&scope, NoneType::object());
for (int i = 0; i <= static_cast<int>(LayoutId::kLastBuiltinId); i++) {
layout = runtime->layoutAtSafe(static_cast<LayoutId>(i));
if (layout.isErrorNotFound()) continue;
layout = runtime->layoutAt(static_cast<LayoutId>(i));
if (layout == SmallInt::fromWord(0)) {
// Indicates an invalid LayoutId.
continue;
}
type_obj = Layout::cast(*layout).describedType();
if (!type_obj.isType()) continue;
if (Type::cast(*type_obj).name() == name) {
Expand Down

0 comments on commit a7b3533

Please sign in to comment.