Project

General

Profile

Actions

Bug #15752

closed

Faster "substituteConstants"

Added by old_hkdennis2k about 18 years ago. Updated almost 18 years ago.

Status:
Closed
Priority:
Should have
Category:
Communication
Target version:
-
Start date:
2006-03-02
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.0
PHP Version:
5
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

"substituteConstants" for typoscript is using loop and str_replace, which has a poor performance. O(M x N).
Neither longer typoscript setup or one more constants(even not used) will increase processing time a lot.

By replacing it into preg_replace_callback, it can finish the job with only 20% of time.

class.t3lib_TStemplate.php
---- 1.27.2.1 on CVS ----
function substituteConstants($all) {
if ($this->tt_track) $GLOBALS['TT']->setTSlogMessage('Constants to substitute: '.count($this->flatSetup));
reset($this->flatSetup);
while (list($const,$val)=each($this->flatSetup)) {
if (!is_array($val)) {
$all = str_replace('{$'.$const.'}',$val,$all);
}
}
return $all;
}
---- modified ----
function substituteConstantsCallBack($matches) {
return isset ($this->flatSetup[$matches1]) ? $this->flatSetup[$matches1] : $matches0;
}
function substituteConstants($all) {
if ($this->tt_track)
$GLOBALS['TT']->setTSlogMessage('Constants to substitute: '.count($this->flatSetup));
return preg_replace_callback('/\{\$(.+?)\}/', array ($this, 'substituteConstantsCallBack'), $all);
}

(issue imported from #M2743)


Files

bug2743_followup.diff (967 Bytes) bug2743_followup.diff Administrator Admin, 2006-03-11 13:30

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #72413: constants replacing in TSOBRejected2015-12-23

Actions
Actions

Also available in: Atom PDF