diff options
author | Matthieu Aubry <matt@piwik.org> | 2015-12-04 03:12:29 +0300 |
---|---|---|
committer | Matthieu Aubry <matt@piwik.org> | 2015-12-04 03:12:29 +0300 |
commit | 6cde84c08d35fc0c49dbf0603e05dbd71f68e5f5 (patch) | |
tree | 925d733fbb09f6751c5b35ce3ca91674efa31de9 /core | |
parent | f0a48bedd88123805f1eee2e029bec9e40e4428e (diff) |
Check whether string actually contains value to prevent from copying the string to reduce memory usage
Diffstat (limited to 'core')
-rw-r--r-- | core/Segment/SegmentExpression.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/core/Segment/SegmentExpression.php b/core/Segment/SegmentExpression.php index 5f1a7fea27..605cd13682 100644 --- a/core/Segment/SegmentExpression.php +++ b/core/Segment/SegmentExpression.php @@ -279,7 +279,7 @@ class SegmentExpression // it can be used internally to inject sub-expressions into the query. // see Segment::getCleanedExpression() $sqlMatch = '%s IN (' . $value['SQL'] . ')'; - $value = $this->escapeLikeString($value['bind']); + $value = $value['bind']; break; default: throw new Exception("Filter contains the match type '" . $matchType . "' which is not supported"); @@ -337,8 +337,14 @@ class SegmentExpression */ private function escapeLikeString($str) { - $str = str_replace("%", "\%", $str); - $str = str_replace("_", "\_", $str); + if (false !== strpos($str, '%')) { + $str = str_replace("%", "\%", $str); + } + + if (false !== strpos($str, '_')) { + $str = str_replace("_", "\_", $str); + } + return $str; } |