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

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: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/text 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 ChildrenVector m_children; 99 ChildrenVector m_children;
100 bool m_isLeaf; 100 bool m_isLeaf;
101 }; 101 };
102 102
103 void build(const String& text) { 103 void build(const String& text) {
104 for (unsigned base = 0; base < text.length(); ++base) { 104 for (unsigned base = 0; base < text.length(); ++base) {
105 Node* current = &m_root; 105 Node* current = &m_root;
106 unsigned limit = std::min(base + m_depth, text.length()); 106 unsigned limit = std::min(base + m_depth, text.length());
107 for (unsigned offset = 0; base + offset < limit; ++offset) { 107 for (unsigned offset = 0; base + offset < limit; ++offset) {
108 ASSERT(current != &m_leaf); 108 DCHECK_NE(current, &m_leaf);
109 Node*& child = current->at(Codebook::codeWord(text[base + offset])); 109 Node*& child = current->at(Codebook::codeWord(text[base + offset]));
110 if (!child) 110 if (!child)
111 child = base + offset + 1 == limit ? &m_leaf : new Node(); 111 child = base + offset + 1 == limit ? &m_leaf : new Node();
112 current = child; 112 current = child;
113 } 113 }
114 } 114 }
115 } 115 }
116 116
117 Node m_root; 117 Node m_root;
118 unsigned m_depth; 118 unsigned m_depth;
119 119
120 // Instead of allocating a fresh empty leaf node for ever leaf in the tree 120 // Instead of allocating a fresh empty leaf node for ever leaf in the tree
121 // (there can be a lot of these), we alias all the leaves to this "static" 121 // (there can be a lot of these), we alias all the leaves to this "static"
122 // leaf node. 122 // leaf node.
123 Node m_leaf; 123 Node m_leaf;
124 }; 124 };
125 125
126 } // namespace blink 126 } // namespace blink
127 127
128 #endif // SuffixTree_h 128 #endif // SuffixTree_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698