summaryrefslogtreecommitdiffstats
path: root/src/datasets
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2009-05-29 07:21:05 +0000
committerKore Nordmann <github@kore-nordmann.de>2009-05-29 07:21:05 +0000
commitbf95cbf5f3c4eefb04a79ad9888e75d9fc2c57cf (patch)
tree73b7c29d86e20bd7fc52ac7ddb1da211c536f70a /src/datasets
parenteb36eb0b72d1e0b01b46f4570c2f6e77ba723e63 (diff)
downloadzetacomponents-graph-bf95cbf5f3c4eefb04a79ad9888e75d9fc2c57cf.zip
zetacomponents-graph-bf95cbf5f3c4eefb04a79ad9888e75d9fc2c57cf.tar.gz
- Fixed #14538: Performance degration for very high numbers of data points
# Test cases with 1000 data points show improvements of about 65% and with 2000 # data points around 85%. # Reduced the number of calls to array functions by better indexing or caching.
Diffstat (limited to 'src/datasets')
-rw-r--r--src/datasets/base.php23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/datasets/base.php b/src/datasets/base.php
index 2ed1a5e..88096d6 100644
--- a/src/datasets/base.php
+++ b/src/datasets/base.php
@@ -67,6 +67,13 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable
protected $pallet;
/**
+ * Array keys
+ *
+ * @var array
+ */
+ protected $keys;
+
+ /**
* Constructor
*
* @return void
@@ -219,13 +226,13 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable
*/
public function current()
{
- $keys = array_keys( $this->data );
if ( !isset( $this->current ) )
{
+ $this->keys = array_keys( $this->data );
$this->current = 0;
}
- return $this->data[$keys[$this->current]];
+ return $this->data[$this->keys[$this->current]];
}
/**
@@ -239,14 +246,13 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable
*/
public function next()
{
- $keys = array_keys( $this->data );
- if ( ++$this->current >= count( $keys ) )
+ if ( ++$this->current >= count( $this->keys ) )
{
return false;
}
else
{
- return $this->data[$keys[$this->current]];
+ return $this->data[$this->keys[$this->current]];
}
}
@@ -261,8 +267,7 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable
*/
public function key()
{
- $keys = array_keys( $this->data );
- return $keys[$this->current];
+ return $this->keys[$this->current];
}
/**
@@ -276,8 +281,7 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable
*/
public function valid()
{
- $keys = array_keys( $this->data );
- return isset( $keys[$this->current] );
+ return isset( $this->keys[$this->current] );
}
/**
@@ -290,6 +294,7 @@ abstract class ezcGraphDataSet implements ArrayAccess, Iterator, Countable
*/
public function rewind()
{
+ $this->keys = array_keys( $this->data );
$this->current = 0;
}
}
OpenPOWER on IntegriCloud