Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84375 - in sandbox/chrono_date: boost/chrono/date boost/chrono/date/detail libs/date/perf libs/date/src
From: vicente.botet_at_[hidden]
Date: 2013-05-19 11:45:53


Author: viboes
Date: 2013-05-19 11:45:52 EDT (Sun, 19 May 2013)
New Revision: 84375
URL: http://svn.boost.org/trac/boost/changeset/84375

Log:
Chrono/Date: make use of int as representation of the ymd_date class fields.
Text files modified:
   sandbox/chrono_date/boost/chrono/date/conversions.hpp | 2
   sandbox/chrono_date/boost/chrono/date/detail/helpers.hpp | 6
   sandbox/chrono_date/boost/chrono/date/ymd_date.hpp | 53 ++++++++-
   sandbox/chrono_date/libs/date/perf/serial_calendar_conversions.cpp | 220 ++++++++++++++++++++--------------------
   sandbox/chrono_date/libs/date/src/conversions.cpp | 30 +++++
   5 files changed, 192 insertions(+), 119 deletions(-)

Modified: sandbox/chrono_date/boost/chrono/date/conversions.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/conversions.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/conversions.hpp 2013-05-19 11:45:52 EDT (Sun, 19 May 2013)
@@ -42,6 +42,8 @@
     days::rep to_days(int_least32_t y, int_least16_t m, int_least16_t d, bool) BOOST_NOEXCEPT;
     void to_ymd(days::rep dt, int& y, int& m, int& d) BOOST_NOEXCEPT;
     void to_ymd(days::rep dt, int_least32_t& y, int_least16_t& m, int_least16_t& d) BOOST_NOEXCEPT;
+ void to_ymd_leap(days::rep dt, int_least32_t& y, int_least32_t& m, int_least32_t& d, int_least32_t& leap) BOOST_NOEXCEPT;
+ void to_ymd_leap(days::rep dt, int_least32_t& y, int_least32_t& m, int_least32_t& d, bool& leap) BOOST_NOEXCEPT;
     void to_ymd_leap(days::rep dt, int_least32_t& y, int_least16_t& m, int_least16_t& d, bool& leap) BOOST_NOEXCEPT;
     void to_ymd_leap(days::rep dt, int_least16_t& y, int_least8_t& m, int_least8_t& d, bool& leap) BOOST_NOEXCEPT;
     //int_least16_t to_ymd_leap(days::rep dt, int_least32_t y, int_least16_t& m, int_least16_t& d, bool& leap) BOOST_NOEXCEPT;

Modified: sandbox/chrono_date/boost/chrono/date/detail/helpers.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/detail/helpers.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/detail/helpers.hpp 2013-05-19 11:45:52 EDT (Sun, 19 May 2013)
@@ -31,19 +31,19 @@
 // typedef boost::int_least32_t day_of_year_rep;
 // typedef boost::int_least32_t year_rep;
 //#endif
- inline BOOST_CONSTEXPR bool
+ BOOST_FORCEINLINE BOOST_CONSTEXPR bool
     is_leap(year_rep y)
     BOOST_NOEXCEPT
     {
       return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
     }
 
- inline BOOST_CONSTEXPR days_rep days_before_year(year_rep y)
+ BOOST_FORCEINLINE BOOST_CONSTEXPR days_rep days_before_year(year_rep y)
     {
       return y * 365 + y / 4 - y / 100 + y / 400;
     }
 
- inline BOOST_CONSTEXPR year_rep
+ BOOST_FORCEINLINE BOOST_CONSTEXPR year_rep
     to_average_year(days_rep ds)
     BOOST_NOEXCEPT
     {

Modified: sandbox/chrono_date/boost/chrono/date/ymd_date.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/ymd_date.hpp (original)
+++ sandbox/chrono_date/boost/chrono/date/ymd_date.hpp 2013-05-19 11:45:52 EDT (Sun, 19 May 2013)
@@ -10,6 +10,7 @@
 #define BOOST_CHRONO_DATE_YMD_DATE_HPP
 
 #define BOOST_CHRONO_DATE_YMD_DATE_HAS_LEAP_FIELD
+//#define BOOST_CHRONO_DATE_YMD_DATE_COMPACT
 
 #include <boost/cstdint.hpp>
 #include <boost/chrono/system_clocks.hpp>
@@ -52,18 +53,36 @@
   #if defined BOOST_CHRONO_DATE_YMD_DATE_HAS_LEAP_FIELD
   #if defined __clang__
         int_least32_t y_;
- int_least16_t m_;
- int_least16_t d_;
+#if defined BOOST_CHRONO_DATE_YMD_DATE_COMPACT
+ int_least16_t m_;
+ int_least16_t d_;
+#else
+ int_least32_t m_;
+ int_least32_t d_;
+#endif
+ bool leap_ ;
   #else
+#if defined BOOST_CHRONO_DATE_YMD_DATE_COMPACT
         int_least16_t y_;
         int_least8_t m_;
         int_least8_t d_;
- #endif
+#else
+ int_least32_t y_;
+ int_least32_t m_;
+ int_least32_t d_;
+#endif
         bool leap_ ;
+ #endif
   #else
+#if defined BOOST_CHRONO_DATE_YMD_DATE_COMPACT
         int_least32_t y_;
         int_least16_t m_;
         int_least16_t d_;
+#else
+ int_least32_t y_;
+ int_least32_t m_;
+ int_least32_t d_;
+#endif
   #endif
 
       public:
@@ -665,18 +684,29 @@
 #if defined BOOST_CHRONO_DATE_YMD_DATE_HAS_LEAP_FIELD
 #if defined __clang__
       int_least32_t y_;
+#if defined BOOST_CHRONO_DATE_YMD_DATE_COMPACT
       int_least16_t m_;
       int_least16_t d_;
 #else
+ int_least32_t m_;
+ int_least32_t d_;
+#endif
+#else
       int_least16_t y_;
       int_least8_t m_;
       int_least8_t d_;
 #endif
       bool leap_ ;
 #else
- int_least32_t y_;
- int_least16_t m_;
- int_least16_t d_;
+#if defined BOOST_CHRONO_DATE_YMD_DATE_COMPACT
+ int_least32_t y_;
+ int_least16_t m_;
+ int_least16_t d_;
+#else
+ int_least32_t y_;
+ int_least32_t m_;
+ int_least32_t d_;
+#endif
 #endif
 
     public:
@@ -817,6 +847,17 @@
       {
       }
 
+ BOOST_FORCEINLINE BOOST_CONSTEXPR ymd_date(chrono::year y, chrono::month m, chrono::day d, no_check_t) BOOST_NOEXCEPT :
+ y_(y),
+ m_(m),
+ d_(d)
+#if defined BOOST_CHRONO_DATE_YMD_DATE_HAS_LEAP_FIELD
+ //, leap_(boost::chrono::is_leap(y_))
+ , leap_(y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))
+#endif
+ {
+ }
+
       /**
        * @Effect Constructs a ymd_date using the year, month_day stored in the arguments as follows:
        * Constructs a ymd_date for which year() == y, month() == month(md), day() == month(md).

Modified: sandbox/chrono_date/libs/date/perf/serial_calendar_conversions.cpp
==============================================================================
--- sandbox/chrono_date/libs/date/perf/serial_calendar_conversions.cpp (original)
+++ sandbox/chrono_date/libs/date/perf/serial_calendar_conversions.cpp 2013-05-19 11:45:52 EDT (Sun, 19 May 2013)
@@ -15,7 +15,7 @@
 volatile boost::int_least16_t m16;
 volatile boost::int_least16_t d16;
 
-#if 0
+#if 1
 void empty_unchecked_ymd_dcl()
 {
   int count = 0;
@@ -91,8 +91,8 @@
         //ymd_date dt((year(y)), month(m), day(d, no_check));
         //ymd_date dt((year(y)), month(m, no_check), day(d));
         //ymd_date dt((year(y)), month(m, no_check), day(d, no_check));
- //ymd_date dt((year(y)), month(m, no_check), day(d, no_check), no_check);
- ymd_date dt((year(y)), month_day(month(m, no_check), day(d, no_check), no_check));
+ ymd_date dt((year(y)), month(m, no_check), day(d, no_check), no_check);
+ //ymd_date dt((year(y)), month_day(month(m, no_check), day(d, no_check), no_check));
         //ymd_date dt((year_month(year(y), month(m, no_check))), day(d, no_check));
         ycount+= day(dt)+month(dt)+year(dt);
 #endif
@@ -105,7 +105,7 @@
   auto encode = t1 - t0;
   std::cout << "unchecked calendar " << sec(encode).count() / count << " " << ycount << '\n';
 }
-#if 0
+#if 1
 
 void checked_month_ymd_dcl()
 {
@@ -538,41 +538,41 @@
 
 int main()
 {
-// empty_checked_ymd_dcl();
-// empty_checked_ymd_dcl();
-// empty_checked_ymd_dcl();
-// empty_checked_ymd_dcl();
-// empty_checked_ymd_dcl();
-// empty_unchecked_ymd_dcl();
-// empty_unchecked_ymd_dcl();
-// empty_unchecked_ymd_dcl();
-// empty_unchecked_ymd_dcl();
-// empty_unchecked_ymd_dcl();
-// checked_day_ymd_dcl();
-// checked_day_ymd_dcl();
-// checked_day_ymd_dcl();
-// checked_day_ymd_dcl();
-// checked_day_ymd_dcl();
-// checked_ymd_dcl();
-// checked_ymd_dcl();
-// checked_ymd_dcl();
-// checked_ymd_dcl();
-// checked_ymd_dcl();
-// checked_ymd_dcl();
-// checked_ymd_dcl();
-// checked_ymd_dcl();
-// checked_ymd_dcl();
-// checked_ymd_dcl();
-// checked_day_ymd_dcl();
-// checked_day_ymd_dcl();
-// checked_day_ymd_dcl();
-// checked_day_ymd_dcl();
-// checked_day_ymd_dcl();
-// checked_month_ymd_dcl();
-// checked_month_ymd_dcl();
-// checked_month_ymd_dcl();
-// checked_month_ymd_dcl();
-// checked_month_ymd_dcl();
+ empty_checked_ymd_dcl();
+ empty_checked_ymd_dcl();
+ empty_checked_ymd_dcl();
+ empty_checked_ymd_dcl();
+ empty_checked_ymd_dcl();
+ empty_unchecked_ymd_dcl();
+ empty_unchecked_ymd_dcl();
+ empty_unchecked_ymd_dcl();
+ empty_unchecked_ymd_dcl();
+ empty_unchecked_ymd_dcl();
+ checked_day_ymd_dcl();
+ checked_day_ymd_dcl();
+ checked_day_ymd_dcl();
+ checked_day_ymd_dcl();
+ checked_day_ymd_dcl();
+ checked_ymd_dcl();
+ checked_ymd_dcl();
+ checked_ymd_dcl();
+ checked_ymd_dcl();
+ checked_ymd_dcl();
+ checked_ymd_dcl();
+ checked_ymd_dcl();
+ checked_ymd_dcl();
+ checked_ymd_dcl();
+ checked_ymd_dcl();
+ checked_day_ymd_dcl();
+ checked_day_ymd_dcl();
+ checked_day_ymd_dcl();
+ checked_day_ymd_dcl();
+ checked_day_ymd_dcl();
+ checked_month_ymd_dcl();
+ checked_month_ymd_dcl();
+ checked_month_ymd_dcl();
+ checked_month_ymd_dcl();
+ checked_month_ymd_dcl();
   unchecked_ymd_dcl();
   unchecked_ymd_dcl();
   unchecked_ymd_dcl();
@@ -593,77 +593,77 @@
   unchecked_ymd_dcl();
   unchecked_ymd_dcl();
   unchecked_ymd_dcl();
-// checked_unchecked_ymd_dcl();
-// checked_unchecked_ymd_dcl();
-// checked_unchecked_ymd_dcl();
-// checked_unchecked_ymd_dcl();
-// checked_unchecked_ymd_dcl();
-// unchecked_checked_ymd_dcl();
-// unchecked_checked_ymd_dcl();
-// unchecked_checked_ymd_dcl();
-// unchecked_checked_ymd_dcl();
-// unchecked_checked_ymd_dcl();
-// empty_checked_ymd_dcl();
-// empty_unchecked_ymd_dcl();
-// checked_ymd_dcl();
-// unchecked_ymd_dcl();
-// checked_unchecked_ymd_dcl();
-// raw_encoding_perf();
-// raw_space_encoding_perf();
-// class_encoding_perf();
-// empty_decoding_perf();
-// raw_decoding_perf();
-// raw_space_decoding_perf();
-// class_decoding_perf();
-// class_decoding_encoding_perf();
-// unchecked_class_decoding_perf();
-// unchecked_class_decoding_encoding_perf();
-// class_decoding_perf();
-// class_decoding_encoding_perf();
-//
-// empty_checked_ymd_dcl();
-// empty_unchecked_ymd_dcl();
-// checked_ymd_dcl();
-// unchecked_ymd_dcl();
-// checked_unchecked_ymd_dcl();
-// empty_checked_ymd_dcl();
-// empty_unchecked_ymd_dcl();
-// checked_ymd_dcl();
-// unchecked_ymd_dcl();
-// checked_unchecked_ymd_dcl();
-// raw_encoding_perf();
-// raw_space_encoding_perf();
-// class_encoding_perf();
-// empty_decoding_perf();
-// raw_decoding_perf();
-// raw_space_decoding_perf();
-// class_decoding_perf();
-// class_decoding_encoding_perf();
-// unchecked_class_decoding_perf();
-// unchecked_class_decoding_encoding_perf();
-// class_decoding_perf();
-// class_decoding_encoding_perf();
-// class_decoding_encoding_perf();
-// class_decoding_encoding_perf();
-// class_decoding_encoding_perf();
-// class_decoding_encoding_perf();
-// unchecked_class_decoding_encoding_perf();
-// unchecked_class_decoding_encoding_perf();
-// unchecked_class_decoding_encoding_perf();
-// unchecked_class_decoding_encoding_perf();
-// unchecked_class_decoding_encoding_perf();
-// unchecked_class_decoding_encoding_perf();
-//
-// class_encoding_decoding_perf();
-// class_encoding_decoding_perf();
-// class_encoding_decoding_perf();
-// class_encoding_decoding_perf();
-// class_encoding_decoding_perf();
-// unchecked_class_encoding_decoding_perf();
-// unchecked_class_encoding_decoding_perf();
-// unchecked_class_encoding_decoding_perf();
-// unchecked_class_encoding_decoding_perf();
-// unchecked_class_encoding_decoding_perf();
+ checked_unchecked_ymd_dcl();
+ checked_unchecked_ymd_dcl();
+ checked_unchecked_ymd_dcl();
+ checked_unchecked_ymd_dcl();
+ checked_unchecked_ymd_dcl();
+ unchecked_checked_ymd_dcl();
+ unchecked_checked_ymd_dcl();
+ unchecked_checked_ymd_dcl();
+ unchecked_checked_ymd_dcl();
+ unchecked_checked_ymd_dcl();
+ empty_checked_ymd_dcl();
+ empty_unchecked_ymd_dcl();
+ checked_ymd_dcl();
+ unchecked_ymd_dcl();
+ checked_unchecked_ymd_dcl();
+ raw_encoding_perf();
+ raw_space_encoding_perf();
+ class_encoding_perf();
+ empty_decoding_perf();
+ raw_decoding_perf();
+ raw_space_decoding_perf();
+ class_decoding_perf();
+ class_decoding_encoding_perf();
+ unchecked_class_decoding_perf();
+ unchecked_class_decoding_encoding_perf();
+ class_decoding_perf();
+ class_decoding_encoding_perf();
+
+ empty_checked_ymd_dcl();
+ empty_unchecked_ymd_dcl();
+ checked_ymd_dcl();
+ unchecked_ymd_dcl();
+ checked_unchecked_ymd_dcl();
+ empty_checked_ymd_dcl();
+ empty_unchecked_ymd_dcl();
+ checked_ymd_dcl();
+ unchecked_ymd_dcl();
+ checked_unchecked_ymd_dcl();
+ raw_encoding_perf();
+ raw_space_encoding_perf();
+ class_encoding_perf();
+ empty_decoding_perf();
+ raw_decoding_perf();
+ raw_space_decoding_perf();
+ class_decoding_perf();
+ class_decoding_encoding_perf();
+ unchecked_class_decoding_perf();
+ unchecked_class_decoding_encoding_perf();
+ class_decoding_perf();
+ class_decoding_encoding_perf();
+ class_decoding_encoding_perf();
+ class_decoding_encoding_perf();
+ class_decoding_encoding_perf();
+ class_decoding_encoding_perf();
+ unchecked_class_decoding_encoding_perf();
+ unchecked_class_decoding_encoding_perf();
+ unchecked_class_decoding_encoding_perf();
+ unchecked_class_decoding_encoding_perf();
+ unchecked_class_decoding_encoding_perf();
+ unchecked_class_decoding_encoding_perf();
+
+ class_encoding_decoding_perf();
+ class_encoding_decoding_perf();
+ class_encoding_decoding_perf();
+ class_encoding_decoding_perf();
+ class_encoding_decoding_perf();
+ unchecked_class_encoding_decoding_perf();
+ unchecked_class_encoding_decoding_perf();
+ unchecked_class_encoding_decoding_perf();
+ unchecked_class_encoding_decoding_perf();
+ unchecked_class_encoding_decoding_perf();
   return 1;
 }
 

Modified: sandbox/chrono_date/libs/date/src/conversions.cpp
==============================================================================
--- sandbox/chrono_date/libs/date/src/conversions.cpp (original)
+++ sandbox/chrono_date/libs/date/src/conversions.cpp 2013-05-19 11:45:52 EDT (Sun, 19 May 2013)
@@ -104,6 +104,36 @@
 // d = day_of_year_day_of_month(leap,doy+1);
 // return y;
 // }
+ void to_ymd_leap(days::rep x_, int_least32_t& y, int_least32_t& m, int_least32_t& d, bool& leap) BOOST_NOEXCEPT
+ {
+ y = static_cast<int_least32_t>(static_cast<int64_t>(x_ + 2) * 400 / 146097);
+ int doy = x_ - days_before_year(y);
+ if (doy < 0)
+ {
+ --y;
+ doy = x_ - days_before_year(y);
+ }
+ //y += (year::first_-1);
+ y -= 32799;
+ leap = is_leap(y);
+ m = day_of_year_month(leap,doy+1);
+ d = day_of_year_day_of_month(leap,doy+1);
+ }
+ void to_ymd_leap(days::rep x_, int_least32_t& y, int_least32_t& m, int_least32_t& d, int_least32_t& leap) BOOST_NOEXCEPT
+ {
+ y = static_cast<int_least32_t>(static_cast<int64_t>(x_ + 2) * 400 / 146097);
+ int doy = x_ - days_before_year(y);
+ if (doy < 0)
+ {
+ --y;
+ doy = x_ - days_before_year(y);
+ }
+ //y += (year::first_-1);
+ y -= 32799;
+ leap = is_leap(y);
+ m = day_of_year_month(leap,doy+1);
+ d = day_of_year_day_of_month(leap,doy+1);
+ }
     void to_ymd_leap(days::rep x_, int_least32_t& y, int_least16_t& m, int_least16_t& d, bool& leap) BOOST_NOEXCEPT
     {
       y = static_cast<int_least32_t>(static_cast<int64_t>(x_ + 2) * 400 / 146097);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk