Our token includes are a big mess. I'd like to merge them into a token.tokens.inc file, and then have 'stub' functions for the core modules in the main token.module.

For example:

token.module:

function token_include() {
  // Do nothing since this function is no longer necessary but still may be called by other modules.
}

function node_token_list($type = 'all') {
  module_load_include('inc', 'token', 'token.tokens');
  return _node_token_list($type);
}

function _node_token_values($type, $object = NULL, $options = array()) {
  module_load_include('inc', 'token', 'token.tokens');
  return _node_token_values($type, $object, $options);
}

token.tokens.inc:

function _node_token_list($type = 'all') {
  // Return the list of node-related tokens from token_node.inc
}

function _node_token_values($type, $object = NULL, $options = array()) {
  // Return the list of node-related values from token_node.inc
}

Comments

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new58.88 KB

Patch for testing that moves all the real token implementations into token.tokens.inc, but leaves the old files blank so we don't get any chance of the old functions staying around.

dave reid’s picture

StatusFileSize
new56.75 KB

Revised patch with some performance test results:

Before patch:
Requests per second:    11.09 [#/sec] (mean)
Time per request:       90.151 [ms] (mean)
Time per request:       90.151 [ms] (mean, across all concurrent requests)
Transfer rate:          6.12 [Kbytes/sec] received

After patch:
Requests per second:    11.10 [#/sec] (mean)
Time per request:       90.124 [ms] (mean)
Time per request:       90.124 [ms] (mean, across all concurrent requests)
Transfer rate:          6.12 [Kbytes/sec] received
dave reid’s picture

StatusFileSize
new57.59 KB
dave reid’s picture

So the patch in #3, reduced the amount of files required for tokens from 4 to 1 (helps with systems like APC enabled), and also reduced the total lines of code by 9 (even while leaving the old token_node.inc, etc files empty since we don't want any problems with people that don't delete module files before upgrading). I'd call that a pretty big win.

damienmckenna’s picture

So there's negligible performance difference, but it'll simplify future maintenance?

Out of interest, what is your plan on removing the (now empty) old inc files?

dave reid’s picture

I figure we keep-em around for a couple releases. They're dead files so they shouldn't even be included by any code.

Status: Needs review » Needs work

The last submitted patch, 922764-token-move-implementations.patch, failed testing.

bluegeek9’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)