Skip to content
Snippets Groups Projects
Commit f7231263 authored by Martin Reddy's avatar Martin Reddy
Browse files

Fix for DEV-39442: Increased the performance of LLDate::toHTTPDateString

by over 50 times.

Looking at the usage, toHTTPDateStream is not called anywhere (except
internally by toHTTPDateString), and toHTTPDateString is called only
once outside of lldate.cpp, by LLStringUtil::formatDatetime. Also, the
method is most commonly called with a single two-character token, such
as "%Y" or "%A".

I therefore removed toHTTPDateStream and optimized toHTTPDateString.
Setting the locale was the most expensive operation, so I looked into
caching that, both in terms of std::ostream and strftime. The timings
for those implementations (averaged over 10 calls) is:

toHTTPDateString timings:
 - with ostream (current)                -> 0.314156 ms
 - with ostream and std::locale caching  -> 0.033999 ms
 - with strftime and setlocale() caching -> 0.005985 ms

I therefore went with the standard C library strftime solution.

I also wrote a few unit tests to make sure that I didn't break any
existing functionality, and tested this under Windows and Linux.

Reviewed by steve.
parent bc106b1b
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment