diff --git a/ink_stroke_modeler/stroke_modeler.cc b/ink_stroke_modeler/stroke_modeler.cc index 54554f9..6458077 100644 --- a/ink_stroke_modeler/stroke_modeler.cc +++ b/ink_stroke_modeler/stroke_modeler.cc @@ -132,7 +132,7 @@ absl::Status StrokeModeler::Update(const Input &input, return absl::InvalidArgumentError("Invalid EventType."); } -absl::Status StrokeModeler::Predict(std::vector &results) { +absl::Status StrokeModeler::Predict(std::vector &results) const { results.clear(); if (!stroke_model_params_.has_value()) { diff --git a/ink_stroke_modeler/stroke_modeler.h b/ink_stroke_modeler/stroke_modeler.h index 00b77b9..84624b0 100644 --- a/ink_stroke_modeler/stroke_modeler.h +++ b/ink_stroke_modeler/stroke_modeler.h @@ -89,7 +89,7 @@ class StrokeModeler { // // The output is limited to results where the predictor has sufficient // confidence. - absl::Status Predict(std::vector& results); + absl::Status Predict(std::vector& results) const; // Saves the current modeler state. // @@ -121,7 +121,9 @@ class StrokeModeler { PositionModeler position_modeler_; StylusStateModeler stylus_state_modeler_; - std::vector tip_state_buffer_; + // This buffer is used as optimization to avoid re-allocating the vector in + // the predictor but doesn't hold state between calls, so can be mutable. + mutable std::vector tip_state_buffer_; struct InputAndCorrectedPosition { Input input;