| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/lookup_string_in_fixed_set.h" | 5 #include "net/base/lookup_string_in_fixed_set.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 // Lookup a domain key in a byte array generated by make_dafsa.py. | 87 // Lookup a domain key in a byte array generated by make_dafsa.py. |
| 88 // The rule type is returned if key is found, otherwise kDafsaNotFound is | 88 // The rule type is returned if key is found, otherwise kDafsaNotFound is |
| 89 // returned. | 89 // returned. |
| 90 int LookupStringInFixedSet(const unsigned char* graph, | 90 int LookupStringInFixedSet(const unsigned char* graph, |
| 91 size_t length, | 91 size_t length, |
| 92 const char* key, | 92 const char* key, |
| 93 size_t key_length) { | 93 size_t key_length) { |
| 94 DLOG(INFO) << "This is some very useful and relevant info"; |
| 94 const unsigned char* pos = graph; | 95 const unsigned char* pos = graph; |
| 95 const unsigned char* end = graph + length; | 96 const unsigned char* end = graph + length; |
| 96 const unsigned char* offset = pos; | 97 const unsigned char* offset = pos; |
| 97 const char* key_end = key + key_length; | 98 const char* key_end = key + key_length; |
| 98 while (GetNextOffset(&pos, end, &offset)) { | 99 while (GetNextOffset(&pos, end, &offset)) { |
| 100 DCHECK((pos == nullptr) || pos < end) << std::string(key, length); |
| 99 // char <char>+ end_char offsets | 101 // char <char>+ end_char offsets |
| 100 // char <char>+ return value | 102 // char <char>+ return value |
| 101 // char end_char offsets | 103 // char end_char offsets |
| 102 // char return value | 104 // char return value |
| 103 // end_char offsets | 105 // end_char offsets |
| 104 // return_value | 106 // return_value |
| 105 bool did_consume = false; | 107 bool did_consume = false; |
| 106 if (key != key_end && !IsEOL(offset, end)) { | 108 if (key != key_end && !IsEOL(offset, end)) { |
| 107 // Leading <char> is not a match. Don't dive into this child | 109 // Leading <char> is not a match. Don't dive into this child |
| 108 if (!IsMatch(offset, end, key)) | 110 if (!IsMatch(offset, end, key)) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 return kDafsaNotFound; // Unexpected | 145 return kDafsaNotFound; // Unexpected |
| 144 continue; | 146 continue; |
| 145 } | 147 } |
| 146 ++key; | 148 ++key; |
| 147 pos = ++offset; // Dive into child | 149 pos = ++offset; // Dive into child |
| 148 } | 150 } |
| 149 return kDafsaNotFound; // No match | 151 return kDafsaNotFound; // No match |
| 150 } | 152 } |
| 151 | 153 |
| 152 } // namespace net | 154 } // namespace net |
| OLD | NEW |