Was looking through module_list() for optimizations, and while in there found a no-op call to drupal_get_filename(), except it's not a no-op call, it actually primes drupal_get_filenames() static cache to avoid it being looked up in subsequent calls to drupal_load(). This has been there since 2005 or earlier, patch just adds some documentation as to why we're doing it.

CommentFileSizeAuthor
#6 filename.patch961 bytescatch
#1 filename.patch754 bytescatch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

FileSize
754 bytes

patch.

moshe weitzman’s picture

Whats the benefit of priming the cache? Why not let it get primed by the first caller?

catch’s picture

drupal_get_filename() does a database hit for every file it looks up unless it's already in the cache - at least that's the behaviour when called from drupal_load() - we're passing the explicit filename we got from the {system} query - so that way it gets the filenames in static instead of having to do it's own lookup.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Needs work

That sounds like useful information to include in this comment. :)

catch’s picture

Status: Needs work » Needs review
FileSize
961 bytes

I knew you'd say that :p

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community
Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.