From 9c1ca606f09709e7fa1ba8211027029a48b92669 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sun, 29 Jun 2014 16:18:08 -0400 Subject: [PATCH] shortcut_catcher: Small refactor to FindPaths() Should be functionally identical. * Removed / after Tracker, thanks Axel. * BString::FindFirst() returns an index not a status_t so check that it finds the path at the start of the string (index 0). * Put paths.CountStrings() in a count variable. I wanted to clean this code up because I use it as a reference. --- .../filters/shortcut_catcher/KeyCommandMap.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/add-ons/input_server/filters/shortcut_catcher/KeyCommandMap.cpp b/src/add-ons/input_server/filters/shortcut_catcher/KeyCommandMap.cpp index 3aa155ba09..04420e4b97 100644 --- a/src/add-ons/input_server/filters/shortcut_catcher/KeyCommandMap.cpp +++ b/src/add-ons/input_server/filters/shortcut_catcher/KeyCommandMap.cpp @@ -1,9 +1,10 @@ /* - * Copyright 1999-2009 Haiku, Inc. All rights reserved. + * Copyright 1999-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Jeremy Friesner + * John Scipione, jscipione@gmail.com */ @@ -266,18 +267,17 @@ KeyCommandMap::MessageReceived(BMessage* message) && message.FindMessage("act", &actuatorMessage) == B_OK && message.FindMessage("modtester", &testerMessage) == B_OK) { - // Leave handling of add-ons shortcuts to Tracker BString command; if (message.FindString("command", &command) == B_OK) { BStringList paths; BPathFinder::FindPaths( - B_FIND_PATH_ADD_ONS_DIRECTORY, "Tracker/", + B_FIND_PATH_ADD_ONS_DIRECTORY, "Tracker", paths); bool foundAddOn = false; - for (int32 i = 0; i < paths.CountStrings(); i++) { - if (command.FindFirst(paths.StringAt(i)) - != B_ERROR) { + int32 count = paths.CountStrings(); + for (int32 i = 0; i < count; i++) { + if (command.FindFirst(paths.StringAt(i)) == 0) { foundAddOn = true; break; }