From cb1d5dbaeba57d6536812536ecbdd87c1bc9d17f Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 3 Nov 2004 22:22:34 +0000 Subject: [PATCH] stl_numeric.h (partial_sum, [...]): Avoid dereferencing two times __first in the prologue. 2004-11-03 Jonathan Wakely * include/bits/stl_numeric.h (partial_sum, adjacent_difference): Avoid dereferencing two times __first in the prologue. From-SVN: r90038 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/include/bits/stl_numeric.h | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 61246af..6848060 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2004-11-03 Jonathan Wakely + + * include/bits/stl_numeric.h (partial_sum, adjacent_difference): + Avoid dereferencing two times __first in the prologue. + 2004-11-03 Paolo Carlini * include/bits/stl_numeric.h: Trivial formatting fixes. diff --git a/libstdc++-v3/include/bits/stl_numeric.h b/libstdc++-v3/include/bits/stl_numeric.h index fc15fe3..a11a040 100644 --- a/libstdc++-v3/include/bits/stl_numeric.h +++ b/libstdc++-v3/include/bits/stl_numeric.h @@ -209,8 +209,8 @@ namespace std if (__first == __last) return __result; - *__result = *__first; _ValueType __value = *__first; + *__result = __value; while (++__first != __last) { __value = __value + *__first; @@ -249,8 +249,8 @@ namespace std if (__first == __last) return __result; - *__result = *__first; _ValueType __value = *__first; + *__result = __value; while (++__first != __last) { __value = __binary_op(__value, *__first); @@ -285,8 +285,8 @@ namespace std if (__first == __last) return __result; - *__result = *__first; _ValueType __value = *__first; + *__result = __value; while (++__first != __last) { _ValueType __tmp = *__first; @@ -324,8 +324,8 @@ namespace std if (__first == __last) return __result; - *__result = *__first; _ValueType __value = *__first; + *__result = __value; while (++__first != __last) { _ValueType __tmp = *__first; -- 2.7.4