From c748fdb404c4f241e195baf1cb24cece7fcf404c Mon Sep 17 00:00:00 2001 From: dellaert Date: Mon, 6 Oct 2014 12:13:52 +0200 Subject: [PATCH] Re-did with move semantics. Dangerously imperative. --- gtsam_unstable/nonlinear/BADFactor.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gtsam_unstable/nonlinear/BADFactor.h b/gtsam_unstable/nonlinear/BADFactor.h index a2240c0a9..c57a1993d 100644 --- a/gtsam_unstable/nonlinear/BADFactor.h +++ b/gtsam_unstable/nonlinear/BADFactor.h @@ -53,12 +53,11 @@ public: typedef std::map MapType; MapType terms; Augmented augmented = expression_.augmented(x); - // copy terms to H, which is pre-allocated to correct size - // TODO apply move semantics + // move terms to H, which is pre-allocated to correct size size_t j = 0; - MapType::const_iterator it = augmented.jacobians().begin(); + MapType::iterator it = augmented.jacobians().begin(); for (; it != augmented.jacobians().end(); ++it) - (*H)[j++] = it->second; + it->second.swap((*H)[j++]); return measurement_.localCoordinates(augmented.value()); } else { const T& value = expression_.value(x);