Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#6 | filename.patch | 961 bytes | catch |
#1 | filename.patch | 754 bytes | catch |
Comments
Comment #1
catchpatch.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedWhats the benefit of priming the cache? Why not let it get primed by the first caller?
Comment #3
catchdrupal_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.
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedComment #5
webchickThat sounds like useful information to include in this comment. :)
Comment #6
catchI knew you'd say that :p
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedComment #9
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks!