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

Side by Side Diff: third_party/WebKit/Source/platform/text/SuffixTree.h

Issue 2811453002: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/text (Closed)
Patch Set: fix Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Adam Barth. All rights reserved. 2 * Copyright (C) 2010 Adam Barth. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 ChildrenVector children_; 98 ChildrenVector children_;
99 bool is_leaf_; 99 bool is_leaf_;
100 }; 100 };
101 101
102 void Build(const String& text) { 102 void Build(const String& text) {
103 for (unsigned base = 0; base < text.length(); ++base) { 103 for (unsigned base = 0; base < text.length(); ++base) {
104 Node* current = &root_; 104 Node* current = &root_;
105 unsigned limit = std::min(base + depth_, text.length()); 105 unsigned limit = std::min(base + depth_, text.length());
106 for (unsigned offset = 0; base + offset < limit; ++offset) { 106 for (unsigned offset = 0; base + offset < limit; ++offset) {
107 ASSERT(current != &leaf_); 107 DCHECK_NE(current, &leaf_);
108 Node*& child = current->at(Codebook::CodeWord(text[base + offset])); 108 Node*& child = current->at(Codebook::CodeWord(text[base + offset]));
109 if (!child) 109 if (!child)
110 child = base + offset + 1 == limit ? &leaf_ : new Node(); 110 child = base + offset + 1 == limit ? &leaf_ : new Node();
111 current = child; 111 current = child;
112 } 112 }
113 } 113 }
114 } 114 }
115 115
116 Node root_; 116 Node root_;
117 unsigned depth_; 117 unsigned depth_;
118 118
119 // Instead of allocating a fresh empty leaf node for ever leaf in the tree 119 // Instead of allocating a fresh empty leaf node for ever leaf in the tree
120 // (there can be a lot of these), we alias all the leaves to this "static" 120 // (there can be a lot of these), we alias all the leaves to this "static"
121 // leaf node. 121 // leaf node.
122 Node leaf_; 122 Node leaf_;
123 }; 123 };
124 124
125 } // namespace blink 125 } // namespace blink
126 126
127 #endif // SuffixTree_h 127 #endif // SuffixTree_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698