Redundant call doubles search time

I found this in app/index.js:312:

CoreCommandRouter.prototype.volumioSearch = function (data) {
  this.pushConsoleMessage('CoreCommandRouter::Search ' + data);
  var asd = this.musicLibrary.search(data);

  return this.musicLibrary.search(data);
};

After digging a bit, it looks like the first call was just to populate a temporary variable for debugging, and that debugging log was removed in commit 0263dd3 from July 5, 2017:

CoreCommandRouter.prototype.volumioSearch = function (data) {
	this.pushConsoleMessage('CoreCommandRouter::Search '+data);
	var asd = this.musicLibrary.search(data);
-	console.log(asd)
	return this.musicLibrary.search(data);
};

It seems to me like removing either the first call or returning the temporary variable would give the same results, just twice as fast:

CoreCommandRouter.prototype.volumioSearch = function (data) {
  this.pushConsoleMessage('CoreCommandRouter::Search ' + data);

  return this.musicLibrary.search(data);
};
1 Like

PR: Remove redundant search by itsjeeves · Pull Request #203 · volumio/volumio3-backend · GitHub

Thanks @jeeves for spotting this! Merged!