Currently the token_get_values() function is a bit inefficient as it iterates over all available token_values hooks. It would be much nicer if the function would only iterate over the hooks needed as they can be quite expensive. This patch adds an additional argument to the token_get_values() function supplying a token pattern. Then the required tokens are extracted and only the needed hook_token_values() functions are invoked. On our installation with about 50 modules this leads to an performance improvement of about 0.5 seconds when opening a node edit form.

See the pathauto.module patch for a use case.

Comments

Status: Needs review » Needs work

The last submitted patch, Pathauto-6.x-1.x-dev-performance.patch, failed testing.

dave reid’s picture

Status: Needs work » Closed (won't fix)

I don't see this actually helping. The main problem is all modules always return all their tokens no matter what. We fixed this in D7 with the improved token API. But I doubt we can fix this without breaking APIs.