Fix when LineSearchMinimizer adds the IterationSummary to Solver::Summary

Previously, even when an iteration was successful, the LineSearchMinimizer
would only add the iteration summary to the Summary object if none
of the convergence tests were passed. This could cause iterations with
significant progress in the last iteration to be mis-reported.

The solution would be correct, but the actual cost would be misreported.

This change changes the order of these operations and ensures that
the iteration summary is added whenever the iteration itself is successful.

Thanks to Daniel Weindl for reporting this.

Change-Id: Iff10eccb49d50ad28127f44e149c17fa466db4ae
diff --git a/internal/ceres/line_search_minimizer.cc b/internal/ceres/line_search_minimizer.cc
index fdde1ca..ca1bc6c 100644
--- a/internal/ceres/line_search_minimizer.cc
+++ b/internal/ceres/line_search_minimizer.cc
@@ -380,6 +380,7 @@
     iteration_summary.cumulative_time_in_seconds =
         WallTimeInSeconds() - start_time
         + summary->preprocessor_time_in_seconds;
+    summary->iterations.push_back(iteration_summary);
 
     // Iterations inside the line search algorithm are considered
     // 'steps' in the broader context, to distinguish these inner
@@ -435,8 +436,6 @@
       VLOG_IF(1, is_not_silent) << "Terminating: " << summary->message;
       break;
     }
-
-    summary->iterations.push_back(iteration_summary);
   }
 }