This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Some std::locale improvements
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 29 Nov 2014 22:58:29 +0000
- Subject: [patch] Some std::locale improvements
- Authentication-results: sourceware.org; auth=none
These are a few small things I noticed while working on the facets,
which I'm going to commit separately.
Tested x86_64-linux and powerpc64-linux, committed to trunk.
commit 384475184b4245ac23cb35a363e7e8d98838ec2e
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sat Nov 29 20:45:10 2014 +0000
* src/c++98/locale_init.cc (locale::_Impl::_Impl(size_t)): Use
new-initializer instead of loop.
* src/c++98/localename.cc (locale::_Impl::_Impl(const char*, size_t)):
Likewise.
diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc
index 2c6dfc5..c007648 100644
--- a/libstdc++-v3/src/c++98/locale_init.cc
+++ b/libstdc++-v3/src/c++98/locale_init.cc
@@ -375,17 +375,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_refcount(__refs), _M_facets(0), _M_facets_size(_GLIBCXX_NUM_FACETS),
_M_caches(0), _M_names(0)
{
- _M_facets = new (&facet_vec) const facet*[_M_facets_size];
- _M_caches = new (&cache_vec) const facet*[_M_facets_size];
- for (size_t __i = 0; __i < _M_facets_size; ++__i)
- _M_facets[__i] = _M_caches[__i] = 0;
+ _M_facets = new (&facet_vec) const facet*[_M_facets_size]();
+ _M_caches = new (&cache_vec) const facet*[_M_facets_size]();
// Name the categories.
- _M_names = new (&name_vec) char*[_S_categories_size];
+ _M_names = new (&name_vec) char*[_S_categories_size]();
_M_names[0] = new (&name_c[0]) char[2];
std::memcpy(_M_names[0], locale::facet::_S_get_c_name(), 2);
- for (size_t __j = 1; __j < _S_categories_size; ++__j)
- _M_names[__j] = 0;
// This is needed as presently the C++ version of "C" locales
// != data in the underlying locale model for __timepunct,
diff --git a/libstdc++-v3/src/c++98/localename.cc b/libstdc++-v3/src/c++98/localename.cc
index e93c846..589f8c6 100644
--- a/libstdc++-v3/src/c++98/localename.cc
+++ b/libstdc++-v3/src/c++98/localename.cc
@@ -184,15 +184,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__try
{
- _M_facets = new const facet*[_M_facets_size];
- for (size_t __i = 0; __i < _M_facets_size; ++__i)
- _M_facets[__i] = 0;
- _M_caches = new const facet*[_M_facets_size];
- for (size_t __j = 0; __j < _M_facets_size; ++__j)
- _M_caches[__j] = 0;
- _M_names = new char*[_S_categories_size];
- for (size_t __k = 0; __k < _S_categories_size; ++__k)
- _M_names[__k] = 0;
+ _M_facets = new const facet*[_M_facets_size]();
+ _M_caches = new const facet*[_M_facets_size]();
+ _M_names = new char*[_S_categories_size]();
// Name the categories.
const char* __smon = __s;
commit e90b7f80d7fcef752a4a89325b1bd02d0533f6c2
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sat Nov 29 18:42:53 2014 +0000
* include/bits/locale_facets/nonio.h (__timepunct): Remove unused
typedef.
(time_get): Likewise. Fix comments.
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.h b/libstdc++-v3/include/bits/locale_facets_nonio.h
index 3e2cc7f..5c1eeb7 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.h
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.h
@@ -179,7 +179,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
public:
// Types:
typedef _CharT __char_type;
- typedef basic_string<_CharT> __string_type;
typedef __timepunct_cache<_CharT> __cache_type;
protected:
@@ -374,7 +373,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef _CharT char_type;
typedef _InIter iter_type;
//@}
- typedef basic_string<_CharT> __string_type;
/// Numpunct facet id.
static locale::id id;
@@ -393,15 +391,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Return preferred order of month, day, and year.
*
- * This function returns an enum from timebase::dateorder giving the
+ * This function returns an enum from time_base::dateorder giving the
* preferred ordering if the format @a x given to time_put::put() only
* uses month, day, and year. If the format @a x for the associated
* locale uses other fields, this function returns
- * timebase::dateorder::noorder.
+ * time_base::dateorder::noorder.
*
* NOTE: The library always returns noorder at the moment.
*
- * @return A member of timebase::dateorder.
+ * @return A member of time_base::dateorder.
*/
dateorder
date_order() const
@@ -548,12 +546,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @brief Return preferred order of month, day, and year.
*
- * This function returns an enum from timebase::dateorder giving the
+ * This function returns an enum from time_base::dateorder giving the
* preferred ordering if the format @a x given to time_put::put() only
* uses month, day, and year. This function is a hook for derived
* classes to change the value returned.
*
- * @return A member of timebase::dateorder.
+ * @return A member of time_base::dateorder.
*/
virtual dateorder
do_date_order() const;