I just noticed that hook_init implementation consumes lots of time. for me around 100-200ms. After tracing the code i noticed that _syntaxhighlighter_get_lib_location does recursive scan on every page.
I suggest using a variable to cache the result or using drupal caching system.
Comments
Comment #1
sinasalek commentedI used this modfied version to test the difference.
Comment #2
sinasalek commentedThere is two solutions :
- Using caching functions like cache_get,cache_set to cache the location
- Using variable and update it whenever user visits syntaxhighlighter admin page
- Both!
Comment #3
mattyoung commentedI implemented lib location caching in variable. Drupal caches variable so storing the location value in variable should be good enough. Try the 'dev' version when the release bot make a new 'dev' release later today, or do cvs checkout of 'HEAD'
Thanks!
Comment #4
sinasalek commentedCool.
The reason for cache solution was to let users update the path simply by clearing the cache like many other modules
Comment #5
mattyoung commented> let users update the path simply by clearing the cache like many other modules
I forgot to mention here: visit the module setting page will cause a re-scan of lib location.
Let me know if this is okay enough.
Comment #6
sinasalek commentedThat's fine for me. Thanks
Comment #7
mattyoung commented~