Commit a77bdc44 authored by Tobias Pape's avatar Tobias Pape Committed by Stefan Marr

Speed up startup/primitive loading by replacing dict with unrolled tuple list

Before:
./som -cp Smalltalk TestSuite/TestHarness.som  0,01s user 0,01s system 4% cpu 0,538 total
After:
./som -cp Smalltalk TestSuite/TestHarness.som  0,01s user 0,01s system 56% cpu 0,027 total
parent 86d632ba
from rpython.rlib.unroll import unrolling_iterable
#
# Captures the known primitives
#
......@@ -31,13 +32,13 @@ def _setup_primitives():
prim_pairs = map(lambda (name, cls):
(name[:name.find("Primitives")], cls),
all_prims)
return dict(prim_pairs)
return prim_pairs
_primitives = _setup_primitives()
_primitives = unrolling_iterable(_setup_primitives())
def primitives_for_class(cls):
key = cls.get_name().get_string()
res = _primitives.get(key, None)
if res is None:
raise PrimitivesNotFound
return res
\ No newline at end of file
name = cls.get_name().get_string()
for key, primitives in _primitives:
if key == name:
return primitives
raise PrimitivesNotFound
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment