From ab1f1b21ee5aab5c652fee69c0d12d2fd2a7eee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Sat, 19 Jul 1997 13:29:45 -0700 Subject: [PATCH] some caches added Rev: lib/master.pike:1.45 --- lib/master.pike | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/master.pike b/lib/master.pike index c73cf8ad21..0f9da44524 100644 --- a/lib/master.pike +++ b/lib/master.pike @@ -1,4 +1,4 @@ -/* $Id: master.pike,v 1.44 1997/05/31 22:03:42 grubba Exp $ +/* $Id: master.pike,v 1.45 1997/07/19 20:29:45 hubbe Exp $ * * Master-file for Pike. */ @@ -247,44 +247,59 @@ object cast_to_object(string oname, string current_file) class dirnode { string dirname; + mapping cache=([]); void create(string name) { dirname=name; } object|program `[](string index) { + mixed ret; + if(zero_type(ret=cache[index])) + { + if(ret) return ret; + return UNDEFINED; + } + object m=((object)"/master"); if(mixed o=m->findmodule(dirname+"/module")) { if(mixed tmp=o->_module_value) o=tmp; - if(o=o[index]) return o; + if(o=o[index]) return cache[index]=o; } index = dirname+"/"+index; if(object o=((object)"/master")->findmodule(index)) { if(mixed tmp=o->_module_value) o=tmp; - return o; + return cache[index]=o; } - return (program) index; + return cache[index]=(program) index; } }; +static mapping(string:mixed) fc=([]); + object findmodule(string fullname) { mixed *stat; object o; + if(!zero_type(o=fc[fullname])) + { + return o; + } + if(mixed *stat=file_stat(fullname+".pmod")) { if(stat[1]==-2) - return dirnode(fullname+".pmod"); + return fc[fullname]=dirnode(fullname+".pmod"); } if(o=low_cast_to_object(fullname+".pmod","/.")) - return o; + return fc[fullname]=o; #if constant(load_module) if(file_stat(fullname+".so")) - return low_cast_to_object(fullname,"/."); + return fc[fullname]=low_cast_to_object(fullname,"/."); #endif - return UNDEFINED; + return fc[fullname]=UNDEFINED; } varargs mixed resolv(string identifier, string current_file) -- GitLab