Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(824)

Unified Diff: net/base/lookup_string_in_fixed_set_unittest.cc

Issue 2649033004: [3 of 4] Speedup GetRegistryLengthImpl() by seeding the DAFSA in reverse
Patch Set: rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/lookup_string_in_fixed_set_unittest.cc
diff --git a/net/base/lookup_string_in_fixed_set_unittest.cc b/net/base/lookup_string_in_fixed_set_unittest.cc
index a97b031141d929fb5148ef7ca580ff119c14b3c3..7a6bc98dc3b791591bcb6839b4042b5579d2f30b 100644
--- a/net/base/lookup_string_in_fixed_set_unittest.cc
+++ b/net/base/lookup_string_in_fixed_set_unittest.cc
@@ -4,8 +4,6 @@
#include "net/base/lookup_string_in_fixed_set.h"
-#include <string.h>
-
#include <algorithm>
#include <limits>
#include <ostream>
@@ -16,6 +14,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
+#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -53,8 +52,9 @@ void PrintTo(const Expectation& expectation, std::ostream* os) {
class LookupStringInFixedSetTest : public testing::TestWithParam<Expectation> {
protected:
template <size_t N>
- int LookupInGraph(const unsigned char(&graph)[N], const char* key) {
- return LookupStringInFixedSet(graph, N, key, strlen(key));
+ int LookupInGraph(const unsigned char (&graph)[N], base::StringPiece key) {
+ std::string rev_key(key.rbegin(), key.rend());
+ return LookupStringInFixedSet(graph, N, rev_key.data(), rev_key.length());
}
};
@@ -77,7 +77,7 @@ void RecursivelyEnumerateDafsaLanguage(
std::vector<std::pair<std::string, int>>* language) {
int result = lookup.GetResultForCurrentSequence();
if (result != kDafsaNotFound) {
- language->emplace_back(std::string(sequence->begin(), sequence->end()),
+ language->emplace_back(std::string(sequence->rbegin(), sequence->rend()),
result);
}
// Try appending each char value.

Powered by Google App Engine
This is Rietveld 408576698