Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#5350 closed Patches (fixed)

Patch for lexical_cast: additional optimizations

Reported by: Antony Polukhin <antoshkka@…> Owned by: Antony Polukhin
Milestone: Boost 1.47.0 Component: lexical_cast
Version: Boost Development Trunk Severity: Optimization
Keywords: Cc: antoshkka@…


Patch to Boost Lexical Cast library, that returns Target directly constructed from Source in cases, when:
1) Source and Target are arithmetics (and not char or wchar_t), and all values of Source are in range of Target
2) Source and Target are both char or both wchar_t
3) Source is array of CharT and Target is std::basic_string<CharT, ...>
4) Source and Target are std::basic_string with same template parameters

It gives performance boost more than 10 times in case 1), about 7 times in case 2), and about 1.5 times in cases 3) and 4).

Existing tests for Boost Lexical Cast library cover considered cases. Patch was successfully tested on Intel 11.1.072, g++-4.4.5, VC++9 compilers.

It has the same behaviour, when casting out of bounds (int -> unsigned int, int -> short, unsigned int -> int). For checking bounds it uses boost::numeric::conversion_traits from <boost/numeric/conversion/conversion_traits.hpp>

Closes the ticket #4397

Was discussed at Boost mailing list

Attachments (1)

lexical_cast.hpp.diff (6.6 KB) - added by Antony Polukhin <antoshkka@…> 7 years ago.
Patch for trunk version of lexical_cast (for revision 70337)

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by Antony Polukhin <antoshkka@…>

Attachment: lexical_cast.hpp.diff added

Patch for trunk version of lexical_cast (for revision 70337)

comment:1 Changed 7 years ago by Antony Polukhin

Owner: changed from nasonov to Antony Polukhin
Status: newassigned

comment:2 Changed 7 years ago by Antony Polukhin

Milestone: To Be DeterminedBoost 1.47.0
Resolution: fixed
Status: assignedclosed

(In [71958]) Fixes #5350. Fixes #4397 More tests (for conversions to float types, for conversions of negative values to unsigned integers)

When aws commiting to svn, supported the wrong number.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Antony Polukhin.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.