stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r653942 - /stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp
Date Tue, 06 May 2008 22:22:59 GMT
Author: sebor
Date: Tue May  6 15:22:58 2008
New Revision: 653942

URL: http://svn.apache.org/viewvc?rev=653942&view=rev
Log:
2008-05-06  Martin Sebor  <sebor@roguewave.com>

	* tests/localization/22.locale.num.get.mt.cpp (rw_opt_nthreads,
	rw_opt_nloops, rw_opt_shared_locale): Removed rw_ prefix used
	by test driver symbols.
	(MyNumData): Added nlen_ and wlen_ data members.
	(thread_func): Avoided computing buffer length and used nlen_
	and wlen_ instead for efficiency.
	(run_test): Computed the length of input and stored in nlen_
	and wlen_.

Modified:
    stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp

Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp?rev=653942&r1=653941&r2=653942&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp Tue May  6 15:22:58
2008
@@ -42,10 +42,10 @@
 
 // default number of threads (will be adjusted to the number
 // of processors/cores later)
-int rw_opt_nthreads = 1;
+int opt_nthreads = 1;
 
 // the number of times each thread should iterate
-int rw_opt_nloops = MAX_LOOPS;
+int opt_nloops = MAX_LOOPS;
 
 #if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
 
@@ -62,7 +62,7 @@
 
 // should all threads share the same set of locale objects instead
 // of creating their own?
-int rw_opt_shared_locale;
+int opt_shared_locale;
 
 /**************************************************************************/
 
@@ -117,11 +117,13 @@
 
     // holds the narrow/wide character representation of value_ and
     // the number of used 'charT' in each buffer.
-    char    ncs_ [BufferSize];
+    char        ncs_ [BufferSize];
+    std::size_t nlen_;   // number of valid characters in buffer
 
 #ifndef _RWSTD_NO_WCHAR_T
 
-    wchar_t wcs_ [BufferSize];
+    wchar_t     wcs_ [BufferSize];
+    std::size_t wlen_;   // number of valid characters in buffer
 
 #endif  // _RWSTD_NO_WCHAR_T
 
@@ -338,7 +340,7 @@
     wio.rdbuf (&wsb);
 #endif // _RWSTD_NO_WCHAR_T
 
-    for (int i = 0; i != rw_opt_nloops; ++i) {
+    for (int i = 0; i != opt_nloops; ++i) {
 
         // fill in the value and results for this locale
         const MyNumData& data = my_num_data [i % nlocales];
@@ -346,8 +348,8 @@
         // construct a named locale and imbue it in the ios object
         // so that the locale is used not only by the num_put facet
         const std::locale loc =
-            rw_opt_shared_locale ? data.locale_
-                                 : std::locale (data.locale_name_);
+            opt_shared_locale ? data.locale_
+                              : std::locale (data.locale_name_);
 
         if (test_char) {
             // exercise the narrow char specialization of the facet
@@ -356,7 +358,7 @@
                 std::use_facet<std::num_get<char> >(loc);
 
             nio.imbue (loc);
-            nsb.pubsetg (data.ncs_, Traits::length (data.ncs_));
+            nsb.pubsetg (data.ncs_, data.nlen_);
 
             test_get_data (data, ng,
                            std::istreambuf_iterator<char>(&nsb),
@@ -377,7 +379,7 @@
                 std::use_facet<std::num_get<wchar_t> >(loc);
 
             wio.imbue (loc);
-            wsb.pubsetg (data.wcs_, WTraits::length (data.wcs_));
+            wsb.pubsetg (data.wcs_, data.wlen_);
 
             test_get_data (data, wp,
                            std::istreambuf_iterator<wchar_t>(&wsb),
@@ -445,6 +447,8 @@
             test_put_data (data, np, std::ostreambuf_iterator<char>(&nsb),
                            nio, ' ', '\0');
 
+            data.nlen_ = std::char_traits<char>::length (data.ncs_);
+
             rw_fatal (!nio.fail (), __FILE__, __LINE__,
                       "num_put<char>::put(...) failed for locale(%#s)",
                       data.locale_name_);
@@ -460,13 +464,15 @@
             test_put_data (data, wp, std::ostreambuf_iterator<wchar_t>(&wsb),
                            wio, L' ', L'\0');
 
+            data.wlen_ = std::char_traits<wchar_t>::length (data.wcs_);
+
             rw_fatal (!wio.fail (), __FILE__, __LINE__,
                       "num_put<wchar_t>::put(...) failed for locale(%#s)",
                       data.locale_name_);
 
 #endif // _RWSTD_NO_WCHAR_T
 
-            if (rw_opt_shared_locale)
+            if (opt_shared_locale)
                 data.locale_ = loc;
 
             nlocales += 1;
@@ -487,8 +493,8 @@
     rw_info (0, 0, 0,
              "testing std::num_get<charT> with %d thread%{?}s%{;}, "
              "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
-             rw_opt_nthreads, 1 != rw_opt_nthreads,
-             rw_opt_nloops, 1 != rw_opt_nloops,
+             opt_nthreads, 1 != opt_nthreads,
+             opt_nloops, 1 != opt_nloops,
              nlocales, int (nlocales), "%#s", locales);
 
     rw_info (0, 0, 0, "exercising std::num_get<char>");
@@ -498,11 +504,11 @@
 
     // create and start a pool of threads and wait for them to finish
     int result =
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
 #ifndef _RWSTD_NO_WCHAR_T
 
@@ -513,11 +519,11 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
     // exercise both the char and the wchar_t specializations
     // at the same time
@@ -530,11 +536,11 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
 #endif   // _RWSTD_NO_WCHAR_T
 
@@ -549,9 +555,9 @@
 
     // set nthreads to the greater of the number of processors
     // and 2 (for uniprocessor systems) by default
-    rw_opt_nthreads = rw_get_cpus ();
-    if (rw_opt_nthreads < 2)
-        rw_opt_nthreads = 2;
+    opt_nthreads = rw_get_cpus ();
+    if (opt_nthreads < 2)
+        opt_nthreads = 2;
 
 #endif   // _RWSTD_REENTRANT
 
@@ -563,10 +569,10 @@
                     "|-nlocales#0 "     // arg must be non-negative
                     "|-locales= "       // must be provided
                     "|-shared-locale# ",
-                    &rw_opt_nloops,
+                    &opt_nloops,
                     int (MAX_THREADS),
-                    &rw_opt_nthreads,
+                    &opt_nthreads,
                     &opt_nlocales,
                     &rw_opt_setlocales,
-                    &rw_opt_shared_locale);
+                    &opt_shared_locale);
 }



Mime
View raw message