← Back to team overview

anewt-developers team mailing list archive

[Branch ~uws/anewt/anewt.uws] Rev 1795: [core] Optimize AnewtContainer::_seed() by avoiding ::_set()

 

------------------------------------------------------------
revno: 1795
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt
timestamp: Tue 2010-10-05 23:14:08 +0200
message:
  [core] Optimize AnewtContainer::_seed() by avoiding ::_set()
      
  Avoid the function call overhead of by not calling
  AnewtContainer::_set() by replicating the two lines of code
  that AnewtContainer::_set() consists of.
  
  The result is a speedup in e.g. the construction of
  AnewtAutoRecord result sets, since a new AnewtContainer
  instance is instantiated and populated for each resulting
  row.
modified:
  core/container.lib.php


--
lp:anewt
https://code.launchpad.net/~uws/anewt/anewt.uws

Your team Anewt developers is subscribed to branch lp:anewt.
To unsubscribe from this branch go to https://code.launchpad.net/~uws/anewt/anewt.uws/+edit-subscription
=== modified file 'core/container.lib.php'
--- core/container.lib.php	2010-03-06 13:58:45 +0000
+++ core/container.lib.php	2010-10-05 21:14:08 +0000
@@ -565,6 +565,7 @@
 	 */
 	function _set($name, $value)
 	{
+		/* Note: keep in sync with AnewtContainer::_seed() */
 		assert('is_string($name)');
 		$name = str_replace('-', '_', $name);
 		$this->__data[$name] = $value;
@@ -618,9 +619,11 @@
 	 */
 	function _seed($data)
 	{
+		/* Note: keep in sync with AnewtContainer::_set() */
 		foreach ($data as $name => $value)
 		{
-			$this->_set($name, $value);
+			$name = str_replace('-', '_', $name);
+			$this->__data[$name] = $value;
 		}
 	}