From 307d7c9e7dbe802838eb7efa9b7762d015b8dcb1 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Mon, 9 Jan 2017 08:12:42 -0500 Subject: [PATCH] Adjustment to Page::isChanged() method to reduce Pages::save() overhead --- wire/core/Page.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/wire/core/Page.php b/wire/core/Page.php index 2efb2c85..e09c6e61 100644 --- a/wire/core/Page.php +++ b/wire/core/Page.php @@ -2561,17 +2561,16 @@ class Page extends WireData implements \Countable, WireMatchable { if(parent::isChanged($what)) return true; $changed = false; if($what) { - $value = $this->get($what); - if(is_object($value) && $value instanceof Wire) - $changed = $value->isChanged(); + $data = array_key_exists($what, $this->data) ? array($this->data[$what]) : array(); } else { - foreach($this->data as $key => $value) { - if(is_object($value) && $value instanceof Wire) - $changed = $value->isChanged(); - if($changed) break; - } + $data = &$this->data; + } + foreach($data as $key => $value) { + if(is_object($value) && $value instanceof Wire) { + $changed = $value->isChanged(); + } + if($changed) break; } - return $changed; }