summaryrefslogtreecommitdiff
path: root/roundcubemail/program
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-12-07 09:29:56 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-12-07 09:29:56 +0000
commit61ffc53ca0fa29e15c895de155ab9cde4c073bf8 (patch)
treee6a63a4f280caa53f8263c33b5430c77fc07754b /roundcubemail/program
parent109c79e9de8a758242c4b1c8a65f62b443f14354 (diff)
- Cleanup + perf. improvement (substr_count() is really fast!)
git-svn-id: https://svn.roundcube.net/trunk@5561 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program')
-rw-r--r--roundcubemail/program/include/rcube_result_index.php6
-rw-r--r--roundcubemail/program/include/rcube_result_thread.php13
2 files changed, 7 insertions, 12 deletions
diff --git a/roundcubemail/program/include/rcube_result_index.php b/roundcubemail/program/include/rcube_result_index.php
index 4decaf9e8..e1e6056f5 100644
--- a/roundcubemail/program/include/rcube_result_index.php
+++ b/roundcubemail/program/include/rcube_result_index.php
@@ -157,9 +157,9 @@ class rcube_result_index
$this->meta['count'] = 0;
$this->meta['length'] = 0;
}
- else
- // @TODO: check performance substr_count() vs. explode()
+ else {
$this->meta['count'] = 1 + substr_count($this->raw_data, self::SEPARATOR_ELEMENT);
+ }
return $this->meta['count'];
}
@@ -185,7 +185,6 @@ class rcube_result_index
public function max()
{
if (!isset($this->meta['max'])) {
- // @TODO: do it by parsing raw_data?
$this->meta['max'] = (int) @max($this->get());
}
@@ -201,7 +200,6 @@ class rcube_result_index
public function min()
{
if (!isset($this->meta['min'])) {
- // @TODO: do it by parsing raw_data?
$this->meta['min'] = (int) @min($this->get());
}
diff --git a/roundcubemail/program/include/rcube_result_thread.php b/roundcubemail/program/include/rcube_result_thread.php
index f0f1356fa..1906f18d1 100644
--- a/roundcubemail/program/include/rcube_result_thread.php
+++ b/roundcubemail/program/include/rcube_result_thread.php
@@ -116,8 +116,9 @@ class rcube_result_thread
if (empty($this->raw_data)) {
$this->meta['count'] = 0;
}
- else
+ else {
$this->meta['count'] = 1 + substr_count($this->raw_data, self::SEPARATOR_ELEMENT);
+ }
if (!$this->meta['count'])
$this->meta['messages'] = 0;
@@ -140,11 +141,9 @@ class rcube_result_thread
$this->meta['messages'] = 0;
}
else {
- $regexp = '/((^|' . preg_quote(self::SEPARATOR_ELEMENT, '/')
- . '|' . preg_quote(self::SEPARATOR_ITEM, '/') . ')[0-9]+)/';
-
- // @TODO: can we do this in a better way?
- $this->meta['messages'] = preg_match_all($regexp, $this->raw_data, $m);
+ $this->meta['messages'] = 1
+ + substr_count($this->raw_data, self::SEPARATOR_ELEMENT)
+ + substr_count($this->raw_data, self::SEPARATOR_ITEM);
}
if ($this->meta['messages'] == 0 || $this->meta['messages'] == 1)
@@ -162,7 +161,6 @@ class rcube_result_thread
public function max()
{
if (!isset($this->meta['max'])) {
- // @TODO: do it by parsing raw_data?
$this->meta['max'] = (int) @max($this->get());
}
return $this->meta['max'];
@@ -177,7 +175,6 @@ class rcube_result_thread
public function min()
{
if (!isset($this->meta['min'])) {
- // @TODO: do it by parsing raw_data?
$this->meta['min'] = (int) @min($this->get());
}
return $this->meta['min'];