VoldNativeService: Minor performance improvement
string::find() looks in every position of the string for a match.
We switch to android::base::StartsWith() so we only look for
a match in the first position.
Test: TreeHugger
Change-Id: Idda1a6b60cab8b4eb4b335921fe0fa38eab724dc
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index c3ad2dc..8445cd8 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -193,8 +193,8 @@
// sandboxId will be in either the format shared:<shared-user-id> or <package-name>
// and <shared-user-id> name has same requirements as <package-name>.
std::size_t nameStartIndex = 0;
- if (sandboxId.find("shared:") == 0) {
- nameStartIndex = 7; // len("shared:")
+ if (android::base::StartsWith(sandboxId, "shared:")) {
+ nameStartIndex = 7; // len("shared:")
}
return checkArgumentPackageName(sandboxId.substr(nameStartIndex));
}