Skip to content

Commit

Permalink
Avoid repeated invalidation while constructing classes
Browse files Browse the repository at this point in the history
This saves about 1 second on STD load time.
  • Loading branch information
sorear committed Oct 25, 2010
1 parent dd75106 commit 71c2d1e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Kernel.cs
Expand Up @@ -500,7 +500,7 @@ public List<DynMetaObject> superclasses
k.subclasses.Remove(wr_this);
}

private void Invalidate() {
public void Invalidate() {
if (mro == null)
return;
List<DynMetaObject> notify = new List<DynMetaObject>();
Expand Down Expand Up @@ -547,7 +547,6 @@ public List<DynMetaObject> superclasses

public void AddMethod(string name, IP6 code) {
local[name] = code;
Invalidate();
}

public void AddPrivateMethod(string name, IP6 code) {
Expand Down Expand Up @@ -1069,6 +1068,7 @@ public class Kernel {
n.AddPrivateMethod(kv.Key, kv.Value);
foreach (KeyValuePair<string, IP6> kv in role.local)
n.AddMethod(kv.Key, kv.Value);
n.Invalidate();
if (role.multiregex != null)
foreach (KeyValuePair<string, List<DynObject>> kv
in role.multiregex)
Expand Down Expand Up @@ -1170,6 +1170,7 @@ class ExitRunloopException : Exception { }
SubMO.OnInvoke = new DynMetaObject.InvokeHandler(SubInvoke);
SubMO.FillProtoClass(new string[] { "outer", "info" });
SubMO.AddMethod("INVOKE", MakeSub(SubInvokeSubSI, null));
SubMO.Invalidate();

ScalarMO = new DynMetaObject("Scalar");
ScalarMO.FillProtoClass(new string[] { "value" });
Expand Down
1 change: 1 addition & 0 deletions src/CLRTypes.pm
Expand Up @@ -27,6 +27,7 @@ my %typedata = (
HasMRO => [m => 'Boolean'],
AddMultiRegex=> [m => 'Void'],
AddMethod => [m => 'Void'],
Invalidate => [m => 'Void'],
AddPrivateMethod => [m => 'Void'],
GetPrivateMethod => [m => 'IP6'],
typeObject => [f => 'IP6'],
Expand Down
2 changes: 2 additions & 0 deletions src/CSharpBackend.pm
Expand Up @@ -284,6 +284,7 @@ sub pkg3 {
CgOp::clr_string($m->name),
CgOp::rawsget($unit->deref($m->body)->{peer}{ps}));
}
push @thaw, CgOp::rawcall(CgOp::rawsget($p), 'Invalidate');
for my $k (sort keys %{ $_->multi_regex_lists }) {
for my $b (@{ $_->multi_regex_lists->{$k} }) {
push @thaw, CgOp::rawcall(CgOp::rawsget($p), 'AddMultiRegex',
Expand Down Expand Up @@ -446,6 +447,7 @@ sub codegen_sub {
CgOp::clr_string($m->[0]),
CgOp::fetch(CgOp::scopedlex($m->[1])));
}
push @build, CgOp::rawcall(CgOp::letvar('!mo'), 'Invalidate');
for my $k (sort keys %{ $obj->multi_regex_lists }) {
for my $b (@{ $obj->multi_regex_lists->{$k} }) {
push @build, CgOp::rawcall(CgOp::letvar('!mo'),
Expand Down

0 comments on commit 71c2d1e

Please sign in to comment.