Skip to content

Commit

Permalink
Merge pull request #28213 from owncloud/improve-query-performance
Browse files Browse the repository at this point in the history
use efficient startsWith implementation, don't check if key exists twice
  • Loading branch information
Vincent Petry authored Jun 29, 2017
2 parents 093b82e + 3a057be commit 68fdcb3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/private/AppFramework/Utility/SimpleContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public function resolve($name) {
*/
public function query($name) {
$name = $this->sanitizeName($name);
if ($this->offsetExists($name)) {
try {
return $this->offsetGet($name);
} else {
} catch (\InvalidArgumentException $ex) {
$object = $this->resolve($name);
$this->registerService($name, function () use ($object) {
return $object;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/ServerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function query($name) {

// In case the service starts with OCA\ we try to find the service in
// the apps container first.
if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) {
if (strrpos($name, 'OCA\\', -strlen($name)) !== false && substr_count($name, '\\') >= 2) {
$segments = explode('\\', $name);
$appContainer = $this->getAppContainer(strtolower($segments[1]));
try {
Expand Down

0 comments on commit 68fdcb3

Please sign in to comment.