| 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 #ifndef COURGETTE_LABEL_MANAGER_H_ | 5 #ifndef COURGETTE_LABEL_MANAGER_H_ |
| 6 #define COURGETTE_LABEL_MANAGER_H_ | 6 #define COURGETTE_LABEL_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <vector> | 11 #include <vector> |
| 9 | 12 |
| 10 #include "base/macros.h" | 13 #include "base/macros.h" |
| 11 #include "courgette/image_utils.h" | 14 #include "courgette/image_utils.h" |
| 12 | 15 |
| 13 namespace courgette { | 16 namespace courgette { |
| 14 | 17 |
| 15 // A container to store and manage Label instances. A key consideration is peak | 18 // A container to store and manage Label instances. A key consideration is peak |
| 16 // memory usage reduction. To this end we preallocate Label instances in bulk, | 19 // memory usage reduction. To this end we preallocate Label instances in bulk, |
| 17 // and carefully control transient memory usage when initializing Labels. | 20 // and carefully control transient memory usage when initializing Labels. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 36 | 39 |
| 37 LabelManager(); | 40 LabelManager(); |
| 38 virtual ~LabelManager(); | 41 virtual ~LabelManager(); |
| 39 | 42 |
| 40 // Initializes |labels_| using RVAs from |rva_visitor|. Each distinct RVA from | 43 // Initializes |labels_| using RVAs from |rva_visitor|. Each distinct RVA from |
| 41 // |rva_visitor| yields a Label with |rva_| assigned as the RVA, and |count_| | 44 // |rva_visitor| yields a Label with |rva_| assigned as the RVA, and |count_| |
| 42 // assigned as the repeat. | 45 // assigned as the repeat. |
| 43 void Read(RvaVisitor* rva_visitor); | 46 void Read(RvaVisitor* rva_visitor); |
| 44 | 47 |
| 45 // Removes |labels_| elements whose |count_| is less than |count_threshold|. | 48 // Removes |labels_| elements whose |count_| is less than |count_threshold|. |
| 46 void RemoveUnderusedLabels(int32 count_threshold); | 49 void RemoveUnderusedLabels(int32_t count_threshold); |
| 47 | 50 |
| 48 // Efficiently searches for a Label that targets |rva|. Returns the pointer to | 51 // Efficiently searches for a Label that targets |rva|. Returns the pointer to |
| 49 // the stored Label instance if found, or null otherwise. | 52 // the stored Label instance if found, or null otherwise. |
| 50 Label* Find(RVA rva); | 53 Label* Find(RVA rva); |
| 51 | 54 |
| 52 // TODO(huangs): Move AssignRemainingIndexes() here. | 55 // TODO(huangs): Move AssignRemainingIndexes() here. |
| 53 | 56 |
| 54 protected: | 57 protected: |
| 55 // The main list of Label instances, sorted by the |rva_| member. | 58 // The main list of Label instances, sorted by the |rva_| member. |
| 56 std::vector<Label> labels_; | 59 std::vector<Label> labels_; |
| 57 | 60 |
| 58 private: | 61 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(LabelManager); | 62 DISALLOW_COPY_AND_ASSIGN(LabelManager); |
| 60 }; | 63 }; |
| 61 | 64 |
| 62 } // namespace courgette | 65 } // namespace courgette |
| 63 | 66 |
| 64 #endif // COURGETTE_LABEL_MANAGER_H_ | 67 #endif // COURGETTE_LABEL_MANAGER_H_ |
| OLD | NEW |