diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2010-06-09 14:02:03 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2010-06-09 14:02:03 +0000 |
commit | 6ef9e52dc64abfac9301b21136cecd951ff2a156 (patch) | |
tree | 8df0c69c4b77b7d3ed16eafe6ee56850101141df /libstdc++-v3 | |
parent | 1d5360463f2a76e89383318f1596bf1efe2040f8 (diff) | |
download | gcc-6ef9e52dc64abfac9301b21136cecd951ff2a156.zip gcc-6ef9e52dc64abfac9301b21136cecd951ff2a156.tar.gz gcc-6ef9e52dc64abfac9301b21136cecd951ff2a156.tar.bz2 |
re PR libstdc++/44413 (inefficient code for std::string::compare on x86-64)
2010-06-09 Paolo Carlini <paolo.carlini@oracle.com>
Revert:
2010-06-09 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/44413
* include/ext/vstring_util.h (__vstring_utility<>::_S_compare):
Simplify, just return -1, 0, 1.
From-SVN: r160476
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/vstring_util.h | 17 |
2 files changed, 20 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 43d1354..84eb514 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2010-06-09 Paolo Carlini <paolo.carlini@oracle.com> + + Revert: + 2010-06-09 Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/44413 + * include/ext/vstring_util.h (__vstring_utility<>::_S_compare): + Simplify, just return -1, 0, 1. + 2010-06-09 Iain Sandoe <iains@gcc.gnu.org> PR bootstrap/43170 diff --git a/libstdc++-v3/include/ext/vstring_util.h b/libstdc++-v3/include/ext/vstring_util.h index a9c88d4..4042f70 100644 --- a/libstdc++-v3/include/ext/vstring_util.h +++ b/libstdc++-v3/include/ext/vstring_util.h @@ -1,7 +1,6 @@ // Versatile string utility -*- C++ -*- -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 -// Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -51,10 +50,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) { typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type; - typedef _Traits traits_type; + typedef _Traits traits_type; typedef typename _Traits::char_type value_type; typedef typename _CharT_alloc_type::size_type size_type; - typedef typename _CharT_alloc_type::difference_type difference_type; + typedef typename _CharT_alloc_type::difference_type difference_type; typedef typename _CharT_alloc_type::pointer pointer; typedef typename _CharT_alloc_type::const_pointer const_pointer; @@ -165,8 +164,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) static int _S_compare(size_type __n1, size_type __n2) { - const difference_type __d = __n1 - __n2; - return __d == 0 ? 0 : (__d > 0 ? 1 : -1); + const difference_type __d = difference_type(__n1 - __n2); + + if (__d > __numeric_traits_integer<int>::__max) + return __numeric_traits_integer<int>::__max; + else if (__d < __numeric_traits_integer<int>::__min) + return __numeric_traits_integer<int>::__min; + else + return int(__d); } }; |