[Bug libstdc++/30203] std::vector::size() 10x speedup (patch)

2006-12-14 Thread charles at rebelbase dot com
--- Comment #4 from charles at rebelbase dot com 2006-12-14 17:59 --- (In reply to comment #2) > Can you test with -O1 or above? > As mentioned in comment #1, this should remove all advatages gained from the > "inlined" version. It does indeed. Thanks for your

[Bug libstdc++/30204] std::vector operator[] 10x speedup (patch)

2006-12-14 Thread charles at rebelbase dot com
--- Comment #5 from charles at rebelbase dot com 2006-12-14 17:58 --- (In reply to comment #1) > -O1 is enough to remove all advantages of this patch. > > Also, that isn't really a fair timing comparison, as you've removed the > function call altogether (I still

[Bug libstdc++/30204] New: std::vector operator[] 10x speedup (patch)

2006-12-13 Thread charles at rebelbase dot com
vector::operator[](size_type) in bits/stl_vector.h is currently implemented as reference operator[](size_type __n) { return *(begin() + __n); } const_reference operator[](size_type __n) const { return *(begin() + __n); } A faster implementation would be:

[Bug libstdc++/30203] New: std::vector::size() 10x speedup (patch)

2006-12-13 Thread charles at rebelbase dot com
vector::size() in bits/stl_vector.h is currently implemented as size_type size() const { return size_type(end() - begin()); } A faster implementation is size_type size() const { return _M_impl._M_finish - _M_impl._M_start; } Which avoids the temporary iterato