mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
53b7f5e6a1
This is based on the paper by Daniel Lemire called "Number parsing at a Gigabyte per second", currently available at https://arxiv.org/abs/2101.11408 An implementation can be found at https://github.com/fastfloat/fast_float To support both strtod like methods and String::to_double we have two different APIs. The parse_first_floating_point gives back both the result, next character to read and the error/out of range status. Out of range here means we rounded to infinity 0. The other API, parse_floating_point_completely, will return a floating point only if the given character range contains just the floating point and nothing else. This can be much faster as we can skip actually computing the value if we notice we did not parse the whole range. Both of these APIs support a very lenient format to be usable in as many places as possible. Also it does not check for "named" values like "nan", "inf", "NAN" etc. Because this can be different for every usage. For integers and small values this new method is not faster and often even a tiny bit slower than the current strtod implementation. However the strtod implementation is wrong for a lot of values and has a much less predictable running time. For correctness this method was tested against known string -> double datasets from https://github.com/nigeltao/parse-number-fxx-test-data This method gives 100% accuracy. The old strtod gave an incorrect value in over 50% of the numbers tested.
35 lines
744 B
CMake
35 lines
744 B
CMake
set(AK_SOURCES
|
|
Assertions.cpp
|
|
Base64.cpp
|
|
FloatingPointStringConversions.cpp
|
|
FlyString.cpp
|
|
Format.cpp
|
|
FuzzyMatch.cpp
|
|
GenericLexer.cpp
|
|
Hex.cpp
|
|
JsonParser.cpp
|
|
JsonPath.cpp
|
|
JsonValue.cpp
|
|
kmalloc.cpp
|
|
LexicalPath.cpp
|
|
Random.cpp
|
|
StackInfo.cpp
|
|
String.cpp
|
|
StringBuilder.cpp
|
|
StringImpl.cpp
|
|
StringUtils.cpp
|
|
StringView.cpp
|
|
Time.cpp
|
|
URL.cpp
|
|
URLParser.cpp
|
|
Utf16View.cpp
|
|
Utf8View.cpp
|
|
UUID.cpp
|
|
)
|
|
# AK sources are included from many different places, such as the Kernel, LibC, and Loader
|
|
list(TRANSFORM AK_SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
|
|
|
|
set(AK_SOURCES ${AK_SOURCES} PARENT_SCOPE)
|
|
|
|
serenity_install_headers(AK)
|
|
serenity_install_sources(AK)
|