8000 [OptionsResolver] fixed two bugs and applied optimization by Tobion · Pull Request #4388 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[OptionsResolver] fixed two bugs and applied optimization #4388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 25, 2012
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[OptionsResolver] small optimization in Options class
  • Loading branch information
Tobion committed May 24, 2012
commit a54ea1b6b24c15476211b8648ce1095241cd596e
8 changes: 3 additions & 5 deletions src/Symfony/Component/OptionsResolver/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,15 @@ public function overload($option, $value)
throw new OptionDefinitionException('Options cannot be overloaded anymore once options have been read.');
}

$newValue = $value;

// Reset lazy flag and locks by default
unset($this->lock[$option]);
unset($this->lazy[$option]);

// If an option is a closure that should be evaluated lazily, store it
// inside a LazyOption instance.
if ($this->isEvaluatedLazily($value)) {
if (self::isEvaluatedLazily($value)) {
$currentValue = isset($this->options[$option]) ? $this->options[$option] : null;
$newValue = new LazyOption($value, $currentValue);
$value = new LazyOption($value, $currentValue);

// Store locks for lazy options to detect cyclic dependencies
$this->lock[$option] = false;
Expand All @@ -158,7 +156,7 @@ public function overload($option, $value)
$this->lazy[$option] = true;
}

$this->options[$option] = $newValue;
$this->options[$option] = $value;
}

/**
Expand Down
0