| OLD | NEW | 
|---|
| 1 // Copyright 2006 The RE2 Authors.  All Rights Reserved. | 1 // Copyright 2006 The RE2 Authors.  All Rights Reserved. | 
| 2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style | 
| 3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 // DESCRIPTION | 5 // DESCRIPTION | 
| 6 // | 6 // | 
| 7 // SparseSet<T>(m) is a set of integers in [0, m). | 7 // SparseSet<T>(m) is a set of integers in [0, m). | 
| 8 // It requires sizeof(int)*m memory, but it provides | 8 // It requires sizeof(int)*m memory, but it provides | 
| 9 // fast iteration through the elements in the set and fast clearing | 9 // fast iteration through the elements in the set and fast clearing | 
| 10 // of the set. | 10 // of the set. | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 47 #ifndef RE2_UTIL_SPARSE_SET_H__ | 47 #ifndef RE2_UTIL_SPARSE_SET_H__ | 
| 48 #define RE2_UTIL_SPARSE_SET_H__ | 48 #define RE2_UTIL_SPARSE_SET_H__ | 
| 49 | 49 | 
| 50 #include "util/util.h" | 50 #include "util/util.h" | 
| 51 | 51 | 
| 52 namespace re2 { | 52 namespace re2 { | 
| 53 | 53 | 
| 54 class SparseSet { | 54 class SparseSet { | 
| 55  public: | 55  public: | 
| 56   SparseSet() | 56   SparseSet() | 
| 57     : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(NULL), valgrind_(Ru
     nningOnValgrind()) {} | 57     : size_(0), max_size_(0), sparse_to_dense_(NULL), dense_(NULL), | 
|  | 58       valgrind_(RunningOnValgrindOrMemorySanitizer()) {} | 
| 58 | 59 | 
| 59   SparseSet(int max_size) { | 60   SparseSet(int max_size) { | 
| 60     max_size_ = max_size; | 61     max_size_ = max_size; | 
| 61     sparse_to_dense_ = new int[max_size]; | 62     sparse_to_dense_ = new int[max_size]; | 
| 62     dense_ = new int[max_size]; | 63     dense_ = new int[max_size]; | 
| 63     valgrind_ = RunningOnValgrind(); | 64     valgrind_ = RunningOnValgrindOrMemorySanitizer(); | 
| 64     // Don't need to zero the memory, but do so anyway | 65     // Don't need to zero the memory, but do so anyway | 
| 65     // to appease Valgrind. | 66     // to appease Valgrind. | 
| 66     if (valgrind_) { | 67     if (valgrind_) { | 
| 67       for (int i = 0; i < max_size; i++) { | 68       for (int i = 0; i < max_size; i++) { | 
| 68         dense_[i] = 0xababababU; | 69         dense_[i] = 0xababababU; | 
| 69         sparse_to_dense_[i] = 0xababababU; | 70         sparse_to_dense_[i] = 0xababababU; | 
| 70       } | 71       } | 
| 71     } | 72     } | 
| 72     size_ = 0; | 73     size_ = 0; | 
| 73   } | 74   } | 
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 170   int* sparse_to_dense_; | 171   int* sparse_to_dense_; | 
| 171   int* dense_; | 172   int* dense_; | 
| 172   bool valgrind_; | 173   bool valgrind_; | 
| 173 | 174 | 
| 174   DISALLOW_EVIL_CONSTRUCTORS(SparseSet); | 175   DISALLOW_EVIL_CONSTRUCTORS(SparseSet); | 
| 175 }; | 176 }; | 
| 176 | 177 | 
| 177 }  // namespace re2 | 178 }  // namespace re2 | 
| 178 | 179 | 
| 179 #endif  // RE2_UTIL_SPARSE_SET_H__ | 180 #endif  // RE2_UTIL_SPARSE_SET_H__ | 
| OLD | NEW | 
|---|