Skip to content

Commit 8b0b8fd

Browse files
committed
Changed Util::find() to use the "find" command when no arguments are specified.
(This significantly improves performance in typical use cases, compared to processing a "print .proplist=.id" collection)
1 parent 6eaeb10 commit 8b0b8fd

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/PEAR2/Net/RouterOS/Util.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,11 @@ public function find()
297297
{
298298
if (func_num_args() === 0) {
299299
if (null === $this->idCache) {
300-
$idCache = array();
301-
foreach ($this->client->sendSync(
302-
new Request($this->menu . '/print .proplist=.id')
303-
)->getAllOfType(Response::TYPE_DATA) as $response) {
304-
$idCache[] = $response->getArgument('.id');
305-
}
306-
$this->idCache = $idCache;
300+
$idCache = $this->client->sendSync(
301+
new Request($this->menu . '/find')
302+
)->getArgument('ret');
303+
$this->idCache = explode(',', $idCache);
304+
return $idCache;
307305
}
308306
return implode(',', $this->idCache);
309307
}

tests/UtilStateAlteringFeaturesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testAdd()
6868
*
6969
* @return void
7070
*/
71-
public function testAddToCache()
71+
public function testAddUpdatingCache()
7272
{
7373
$this->util->changeMenu('/queue/simple');
7474
$beforeCount = substr_count($this->util->find(), ',');

0 commit comments

Comments
 (0)