This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] Avoid excess operator*() in stl_numeric
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Cc: Jonathan Wakely <cow at compsoc dot man dot ac dot uk>
- Date: Wed, 03 Nov 2004 11:35:54 +0100
- Subject: [Patch] Avoid excess operator*() in stl_numeric
Hi,
Jon sent me privately the below: seems abviously correct and
actually the prologue becomes similar to the body, sweet!
Tested x86-linux, if nobody objects will commit later today.
Paolo.
//////////////////
2004-11-03 Jonathan Wakely <redi@gcc.gnu.org>
* include/bits/stl_numeric.h (partial_sum, adjacent_difference):
Avoid dereferencing __first two times in the prologue.
diff -urN libstdc++-v3-orig/include/bits/stl_numeric.h libstdc++-v3/include/bits/stl_numeric.h
--- libstdc++-v3-orig/include/bits/stl_numeric.h 2004-11-03 10:51:26.000000000 +0100
+++ libstdc++-v3/include/bits/stl_numeric.h 2004-11-03 11:18:50.000000000 +0100
@@ -209,8 +209,8 @@
if (__first == __last)
return __result;
- *__result = *__first;
_ValueType __value = *__first;
+ *__result = __value;
while (++__first != __last)
{
__value = __value + *__first;
@@ -249,8 +249,8 @@
if (__first == __last)
return __result;
- *__result = *__first;
_ValueType __value = *__first;
+ *__result = __value;
while (++__first != __last)
{
__value = __binary_op(__value, *__first);
@@ -285,8 +285,8 @@
if (__first == __last)
return __result;
- *__result = *__first;
_ValueType __value = *__first;
+ *__result = __value;
while (++__first != __last)
{
_ValueType __tmp = *__first;
@@ -324,8 +324,8 @@
if (__first == __last)
return __result;
- *__result = *__first;
_ValueType __value = *__first;
+ *__result = __value;
while (++__first != __last)
{
_ValueType __tmp = *__first;