summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorBryan O'Sullivan <bos@lindenlab.com>2009-09-09 17:10:06 -0700
committerBryan O'Sullivan <bos@lindenlab.com>2009-09-09 17:10:06 -0700
commita997e131d4262f0a18a6f4f8c305c73edbfea6b6 (patch)
tree5b7f8595e7911f4fd7ba6f2824c6b92f8478a9ef /indra/llcommon
parentcab31b572d1a3b717b7f8b9fdf2a49f0b2eb6995 (diff)
parentbbf497469c4d71d5308421f1ef06d0a2098772c8 (diff)
Merge with SVN viewer-2.0.0-3 branch
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/linden_common.h3
-rw-r--r--indra/llcommon/lldate.cpp33
-rw-r--r--indra/llcommon/lldate.h1
-rw-r--r--indra/llcommon/llstring.h4
4 files changed, 18 insertions, 23 deletions
diff --git a/indra/llcommon/linden_common.h b/indra/llcommon/linden_common.h
index 9adf24a492..8687a24655 100644
--- a/indra/llcommon/linden_common.h
+++ b/indra/llcommon/linden_common.h
@@ -87,7 +87,8 @@
#include "lldefs.h"
#include "llerror.h"
#include "llextendedstatus.h"
-#include "llfasttimer.h"
+// Don't do this, adds 15K lines of header code to every library file.
+//#include "llfasttimer.h"
#include "llfile.h"
#include "llformat.h"
diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp
index 6a82a848be..41150ad057 100644
--- a/indra/llcommon/lldate.cpp
+++ b/indra/llcommon/lldate.cpp
@@ -38,7 +38,7 @@
#include "apr_time.h"
#include <time.h>
-#include <locale>
+#include <locale.h>
#include <string>
#include <iomanip>
#include <sstream>
@@ -100,33 +100,28 @@ std::string LLDate::toHTTPDateString (std::string fmt) const
{
LLFastTimer ft1(FT_DATE_FORMAT);
- std::ostringstream stream;
time_t locSeconds = (time_t) mSecondsSinceEpoch;
struct tm * gmt = gmtime (&locSeconds);
-
- stream.imbue (std::locale(LLStringUtil::getLocale().c_str()));
- toHTTPDateStream (stream, gmt, fmt);
- return stream.str();
+ return toHTTPDateString(gmt, fmt);
}
std::string LLDate::toHTTPDateString (tm * gmt, std::string fmt)
{
LLFastTimer ft1(FT_DATE_FORMAT);
-
- std::ostringstream stream;
- stream.imbue (std::locale(LLStringUtil::getLocale().c_str()));
- toHTTPDateStream (stream, gmt, fmt);
- return stream.str();
-}
-void LLDate::toHTTPDateStream(std::ostream& s, tm * gmt, std::string fmt)
-{
- LLFastTimer ft1(FT_DATE_FORMAT);
+ // avoid calling setlocale() unnecessarily - it's expensive.
+ static std::string prev_locale = "";
+ std::string this_locale = LLStringUtil::getLocale();
+ if (this_locale != prev_locale)
+ {
+ setlocale(LC_TIME, this_locale.c_str());
+ prev_locale = this_locale;
+ }
- const char * pBeg = fmt.c_str();
- const char * pEnd = pBeg + fmt.length();
- const std::time_put<char>& tp = std::use_facet<std::time_put<char> >(s.getloc());
- tp.put (s, s, s.fill(), gmt, pBeg, pEnd);
+ // use strftime() as it appears to be faster than std::time_put
+ char buffer[128];
+ strftime(buffer, 128, fmt.c_str(), gmt);
+ return std::string(buffer);
}
void LLDate::toStream(std::ostream& s) const
diff --git a/indra/llcommon/lldate.h b/indra/llcommon/lldate.h
index 23d3b900f8..9dcce9117f 100644
--- a/indra/llcommon/lldate.h
+++ b/indra/llcommon/lldate.h
@@ -86,7 +86,6 @@ public:
void toStream(std::ostream&) const;
std::string toHTTPDateString (std::string fmt) const;
static std::string toHTTPDateString (tm * gmt, std::string fmt);
- static void toHTTPDateStream(std::ostream&, tm *, std::string);
/**
* @brief Set the date from an ISO-8601 string.
*
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 3b1379c76a..d0def896cf 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -36,7 +36,6 @@
#include <string>
#include <locale>
#include <iomanip>
-#include <boost/regex.hpp>
#include "llsd.h"
#include "llfasttimer.h"
@@ -232,7 +231,6 @@ public:
typedef std::map<LLFormatMapString, LLFormatMapString> format_map_t;
static void getTokens(const std::basic_string<T>& instr, std::vector<std::basic_string<T> >& tokens, const std::basic_string<T>& delims);
- static size_type getSubstitution(const std::basic_string<T>& instr, size_type& start, std::vector<std::basic_string<T> >& tokens);
static void formatNumber(std::basic_string<T>& numStr, std::basic_string<T> decimals);
static bool formatDatetime(std::basic_string<T>& replacement, std::basic_string<T> token, std::basic_string<T> param, S32 secFromEpoch);
static S32 format(std::basic_string<T>& s, const format_map_t& substitutions);
@@ -347,6 +345,8 @@ public:
static void testHarness();
#endif
+private:
+ static size_type getSubstitution(const std::basic_string<T>& instr, size_type& start, std::vector<std::basic_string<T> >& tokens);
};
template<class T> std::basic_string<T> LLStringUtilBase<T>::null;