This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
What really happens when I constify and tweak? ;)
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 27 Oct 2003 15:56:38 +0100
- Subject: What really happens when I constify and tweak? ;)
Hi,
today, I wanted to start investigating what really happens
when I tweak something here and there...
Indeed, some changes are obviously correct but often, I
realized, I don't know /quantitatively/ the effect.
Consider this instantiation of the __verify_grouping for
chars we had 'til a few days ago:
#include <string>
bool
__verify_grouping(const std::string& __grouping,
std::string& __grouping_tmp)
{
size_t __i = 0;
size_t __j = 0;
const size_t __len = __grouping.size();
const size_t __n = __grouping_tmp.size();
bool __test = true;
while (__test && __i < __n - 1)
for (__j = 0; __test && __j < __len && __i < __n - 1; ++__j, ++__i)
__test &= __grouping[__j] == __grouping_tmp[__n - __i - 1];
__j == __len ? __j = 0 : __j;
__test &= __grouping[__j] >= __grouping_tmp[__n - __i - 1];
return __test;
}
Let us begin with a very simple statistic, object file size. So let
us compile it with current mainline on i686-linux, -O2, then strip:
Size: 1028 bytes.
Then, let us remove the redundant '&' in the loop, as I did recently:
Size: 984 bytes.
Then, let us constify the second parameter, as I will do later today:
Size: 656 bytes.
Pretty impressive, isn't it? ;)
Cheers,
Paolo.