optimization_guide: Miscellaneous cleanup around PredictionModel.
* PredictionModel was using SequenceChecker incorrectly, to no effect. Since the fields it was guarding are immutable, this sequence check was in any event unnecessary. Instead, the members have been made const. * PredictionModel::model_info_ was never set or read. It is removed. * The PredictionModel constructor has been made explicit, consistent with Chromium style. * The code was very inconsistent about whether optimization_guide:: qualification was used. For consistency, brevity and style it has been rewritten in these places to not be qualified. * It is inefficient to construct a flat_set by repeated insertion. It is equally easy, and preferred (see base/containers/flat_set.h) to construct a vector that can be sorted on construction. This reduces complexity from O(n^2) to O(n log n). * PredictionModel::GetModelFeatures returned a copy, unneecessarily. It now returns a const reference. * Fewer conversions between std::unique_ptr<proto::PredictionModel> and const proto::PredictionModel& are now done. std::unique_ptr is left where ownership is passed or where it interfaces with other code that uses unique_ptr in a more complicated way. This reduces copies and heap allocations. Regrettably it requires a number of trivial changes to the unit tests. * DecisionTreePredictionModel::ValidateTreeNode's node_index argument is changed to int, which is more efficient and more usual than const int&. Change-Id: Ib6b9d77d4f5941f578d3213c323ead01319715b2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2607485 Commit-Queue: Jeremy Roman <jbroman@chromium.org> Reviewed-by:Sophie Chang <sophiechang@chromium.org> Cr-Commit-Position: refs/heads/master@{#840333}
Showing
This diff is collapsed.
This diff is collapsed.
Please register or sign in to comment