From e6f142be17480715e2c9f3c6091088cd5ec8751f Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 10 Nov 2015 17:41:12 -0500 Subject: [PATCH] ISO8601: Moved ::parse_epoch to occur first --- src/ISO8601.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ISO8601.cpp b/src/ISO8601.cpp index 90b4bb3e1..91eb9bee9 100644 --- a/src/ISO8601.cpp +++ b/src/ISO8601.cpp @@ -232,7 +232,16 @@ bool ISO8601d::parse ( { auto i = start; Nibbler n (input.substr (i)); - if (parse_formatted (n, format)) + + // Parse epoch first, as it's the most common scenario. + if (parse_epoch (n)) + { + // ::validate and ::resolve are not needed in this case. + start = n.cursor (); + return true; + } + + else if (parse_formatted (n, format)) { // Check the values and determine time_t. if (validate ()) @@ -265,8 +274,7 @@ bool ISO8601d::parse ( } } - else if (parse_epoch (n) || - parse_named (n)) + else if (parse_named (n)) { // ::validate and ::resolve are not needed in this case. start = n.cursor ();