On Fri, Aug 15, 2008 at 11:10 AM, Marcus Griep <marcus@xxxxxxxx> wrote: > This will ensure that the API at large is accessible to nearly > all Perl versions, while only the temp file caching API is tied to > the File::Temp and File::Spec modules being available. > > Signed-off-by: Marcus Griep <marcus@xxxxxxxx> > --- > > Eric Wong wrote: > > What about just lazy requiring inside _temp_cache() so it > > won't get loaded by folks that don't need it? (completely untested): > > > > eval { require File::Temp }; > > if ($@) { > > throw Error::Simple("couldn't require File::Temp: $@"); > > } > > eval { require File::Spec }; > > if ($@) { > > throw Error::Simple("couldn't require File::Spec: $@"); > > } > > > > It'll also remove the minor performance hit CGI/gitweb users got since > > we won't load these extra modules during startup. > > This recommendation is implemented with this patch, but in such a way that only > the first test will be used, and that result cached. That way we aren't doing > a compile _every_ time we want a temporary file, just the first time. perl's 'require' will only attempt to load a module the first time it is used; subsequent attempts will result in a quick no-op, so there's no need to further cache. Unless you mean to cache a negative result? In which case, the require should be quite fast, as it'll quickly get a 'file not found' error without needing to do any compilation. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html