Skip to content
Snippets Groups Projects
Commit ab1f1b21 authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

some caches added

Rev: lib/master.pike:1.45
parent 05c7cd21
Branches
Tags
No related merge requests found
/* $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. * Master-file for Pike.
*/ */
...@@ -247,44 +247,59 @@ object cast_to_object(string oname, string current_file) ...@@ -247,44 +247,59 @@ object cast_to_object(string oname, string current_file)
class dirnode class dirnode
{ {
string dirname; string dirname;
mapping cache=([]);
void create(string name) { dirname=name; } void create(string name) { dirname=name; }
object|program `[](string index) object|program `[](string index)
{ {
mixed ret;
if(zero_type(ret=cache[index]))
{
if(ret) return ret;
return UNDEFINED;
}
object m=((object)"/master"); object m=((object)"/master");
if(mixed o=m->findmodule(dirname+"/module")) if(mixed o=m->findmodule(dirname+"/module"))
{ {
if(mixed tmp=o->_module_value) o=tmp; 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; index = dirname+"/"+index;
if(object o=((object)"/master")->findmodule(index)) if(object o=((object)"/master")->findmodule(index))
{ {
if(mixed tmp=o->_module_value) o=tmp; 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) object findmodule(string fullname)
{ {
mixed *stat; mixed *stat;
object o; object o;
if(!zero_type(o=fc[fullname]))
{
return o;
}
if(mixed *stat=file_stat(fullname+".pmod")) if(mixed *stat=file_stat(fullname+".pmod"))
{ {
if(stat[1]==-2) if(stat[1]==-2)
return dirnode(fullname+".pmod"); return fc[fullname]=dirnode(fullname+".pmod");
} }
if(o=low_cast_to_object(fullname+".pmod","/.")) if(o=low_cast_to_object(fullname+".pmod","/."))
return o; return fc[fullname]=o;
#if constant(load_module) #if constant(load_module)
if(file_stat(fullname+".so")) if(file_stat(fullname+".so"))
return low_cast_to_object(fullname,"/."); return fc[fullname]=low_cast_to_object(fullname,"/.");
#endif #endif
return UNDEFINED; return fc[fullname]=UNDEFINED;
} }
varargs mixed resolv(string identifier, string current_file) varargs mixed resolv(string identifier, string current_file)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment