Skip to content

Commit

Permalink
Use the fast_float library to parse floating-point numbers
Browse files Browse the repository at this point in the history
This commit brings in the amalgamated header of the fast_float library,
and applies it to our uses of sscanf with %f.

This library is locale-free, and does not incur the performance penalty of
using a thread locale RAII class.

Fixes AcademySoftwareFoundation#297
Fixes AcademySoftwareFoundation#379
Fixes AcademySoftwareFoundation#1022
  • Loading branch information
amyspark committed Sep 20, 2021
1 parent 9bc9711 commit f9b26eb
Show file tree
Hide file tree
Showing 8 changed files with 3,151 additions and 3 deletions.
52 changes: 52 additions & 0 deletions THIRD-PARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,56 @@ England

---------------------------------------------------------------------

fast_float number parsing library, courtesy of The fast_float authors.
https://github.com/fastfloat/fast_float/

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this repository by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

(the terms of the Apache License follow)

Copyright 2020 The fast_float authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

(the terms of the MIT License follow)

Copyright 2020 The fast_float authors

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

---------------------------------------------------------------------

If we have left anything out, it is unintentional. Please let us know.
2 changes: 2 additions & 0 deletions ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@

# Sample ICC (modified)
add_subdirectory(sampleicc)

add_subdirectory(fast_float)
9 changes: 9 additions & 0 deletions ext/fast_float/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.

# fast_float amalgamated header
# https://github.com/fastfloat/fast_float
add_library(fast_float::fast_float INTERFACE IMPORTED GLOBAL)
set_target_properties(fast_float::fast_float PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/src/include"
)
12 changes: 12 additions & 0 deletions ext/fast_float/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fast_float number parsing library: 4x faster than strtod
========================================================

The fast_float library provides fast header-only implementations for the C++ from_chars
functions for `float` and `double` types. These functions convert ASCII strings representing
decimal values (e.g., `1.3e10`) into binary types. We provide exact rounding (including
round to even). In our experience, these `fast_float` functions many times faster than comparable number-parsing functions from existing C++ standard libraries.

This is the amalgamated header of version 3.1.0, available at:

https://github.com/fastfloat/fast_float/releases/tag/v3.1.0

Loading

0 comments on commit f9b26eb

Please sign in to comment.