Remove unused dtoa code
This commit is contained in:
@@ -926,8 +926,6 @@ list(APPEND SRC_FILES
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/color.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/constants.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/convert.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/dtoa.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/dtoa.hpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/event.cpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/filesystem.hpp
|
||||
${PROJECT_SOURCE_DIR}/src/mbgl/util/font_stack.cpp
|
||||
|
||||
@@ -582,8 +582,6 @@ MLN_CORE_SOURCE = [
|
||||
"src/mbgl/util/color.cpp",
|
||||
"src/mbgl/util/constants.cpp",
|
||||
"src/mbgl/util/convert.cpp",
|
||||
"src/mbgl/util/dtoa.cpp",
|
||||
"src/mbgl/util/dtoa.hpp",
|
||||
"src/mbgl/util/event.cpp",
|
||||
"src/mbgl/util/filesystem.hpp",
|
||||
"src/mbgl/util/font_stack.cpp",
|
||||
|
||||
@@ -10,7 +10,6 @@ add_library(
|
||||
${PROJECT_SOURCE_DIR}/benchmark/parse/vector_tile.benchmark.cpp
|
||||
${PROJECT_SOURCE_DIR}/benchmark/src/mbgl/benchmark/benchmark.cpp
|
||||
${PROJECT_SOURCE_DIR}/benchmark/storage/offline_database.benchmark.cpp
|
||||
${PROJECT_SOURCE_DIR}/benchmark/util/dtoa.benchmark.cpp
|
||||
${PROJECT_SOURCE_DIR}/benchmark/util/tilecover.benchmark.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include <mbgl/util/dtoa.hpp>
|
||||
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
static void Util_dtoa(::benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
util::dtoa(0.);
|
||||
util::dtoa(M_E);
|
||||
util::dtoa(M_LOG2E);
|
||||
util::dtoa(M_LOG10E);
|
||||
util::dtoa(M_LN2);
|
||||
util::dtoa(M_LN10);
|
||||
util::dtoa(M_PI);
|
||||
util::dtoa(M_PI_2);
|
||||
util::dtoa(M_PI_4);
|
||||
util::dtoa(M_1_PI);
|
||||
util::dtoa(M_2_PI);
|
||||
util::dtoa(M_2_SQRTPI);
|
||||
util::dtoa(M_SQRT2);
|
||||
util::dtoa(M_SQRT1_2);
|
||||
}
|
||||
}
|
||||
|
||||
static void Util_standardDtoa(::benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
std::ignore = std::to_string(0.);
|
||||
std::ignore = std::to_string(M_E);
|
||||
std::ignore = std::to_string(M_LOG2E);
|
||||
std::ignore = std::to_string(M_LOG10E);
|
||||
std::ignore = std::to_string(M_LN2);
|
||||
std::ignore = std::to_string(M_LN10);
|
||||
std::ignore = std::to_string(M_PI);
|
||||
std::ignore = std::to_string(M_PI_2);
|
||||
std::ignore = std::to_string(M_PI_4);
|
||||
std::ignore = std::to_string(M_1_PI);
|
||||
std::ignore = std::to_string(M_2_PI);
|
||||
std::ignore = std::to_string(M_2_SQRTPI);
|
||||
std::ignore = std::to_string(M_SQRT2);
|
||||
std::ignore = std::to_string(M_SQRT1_2);
|
||||
}
|
||||
}
|
||||
|
||||
static void Util_dtoaLimits(::benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
util::dtoa(DBL_MIN);
|
||||
util::dtoa(DBL_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
static void Util_standardDtoaLimits(::benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
std::ignore = std::to_string(DBL_MIN);
|
||||
std::ignore = std::to_string(DBL_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(Util_dtoa);
|
||||
BENCHMARK(Util_standardDtoa);
|
||||
|
||||
BENCHMARK(Util_dtoaLimits);
|
||||
BENCHMARK(Util_standardDtoaLimits);
|
||||
@@ -1,22 +0,0 @@
|
||||
#include "dtoa.hpp"
|
||||
|
||||
#include <rapidjson/internal/dtoa.h>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
std::string dtoa(double value, bool decimal) {
|
||||
std::string data;
|
||||
data.resize(25);
|
||||
auto end = rapidjson::internal::dtoa(value, const_cast<char*>(data.data()));
|
||||
auto length = end - data.data();
|
||||
if (!decimal && length >= 3 && end[-1] == '0' && end[-2] == '.') {
|
||||
// Remove trailing ".0" for integers
|
||||
length -= 2;
|
||||
}
|
||||
data.resize(length);
|
||||
return data;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace mbgl
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
std::string dtoa(double value, bool decimal = false);
|
||||
|
||||
inline double stod(const std::string& str) {
|
||||
return ::strtod(str.c_str(), nullptr);
|
||||
}
|
||||
|
||||
} // end namespace util
|
||||
} // end namespace mbgl
|
||||
@@ -86,7 +86,6 @@ add_library(
|
||||
${PROJECT_SOURCE_DIR}/test/util/async_task.test.cpp
|
||||
${PROJECT_SOURCE_DIR}/test/util/bounding_volumes.test.cpp
|
||||
${PROJECT_SOURCE_DIR}/test/util/camera.test.cpp
|
||||
${PROJECT_SOURCE_DIR}/test/util/dtoa.test.cpp
|
||||
${PROJECT_SOURCE_DIR}/test/util/geo.test.cpp
|
||||
${PROJECT_SOURCE_DIR}/test/util/grid_index.test.cpp
|
||||
${PROJECT_SOURCE_DIR}/test/util/hash.test.cpp
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
#include <mbgl/test/util.hpp>
|
||||
|
||||
#include <mbgl/util/dtoa.hpp>
|
||||
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
TEST(Dtoa, Precision) {
|
||||
EXPECT_EQ(M_E, util::stod(util::dtoa(M_E)));
|
||||
EXPECT_EQ(M_LOG2E, util::stod(util::dtoa(M_LOG2E)));
|
||||
EXPECT_EQ(M_LOG10E, util::stod(util::dtoa(M_LOG10E)));
|
||||
EXPECT_EQ(M_LN2, util::stod(util::dtoa(M_LN2)));
|
||||
EXPECT_EQ(M_LN10, util::stod(util::dtoa(M_LN10)));
|
||||
EXPECT_EQ(M_PI, util::stod(util::dtoa(M_PI)));
|
||||
EXPECT_EQ(M_PI_2, util::stod(util::dtoa(M_PI_2)));
|
||||
EXPECT_EQ(M_PI_4, util::stod(util::dtoa(M_PI_4)));
|
||||
EXPECT_EQ(M_1_PI, util::stod(util::dtoa(M_1_PI)));
|
||||
EXPECT_EQ(M_2_PI, util::stod(util::dtoa(M_2_PI)));
|
||||
EXPECT_EQ(M_2_SQRTPI, util::stod(util::dtoa(M_2_SQRTPI)));
|
||||
EXPECT_EQ(M_SQRT2, util::stod(util::dtoa(M_SQRT2)));
|
||||
EXPECT_EQ(M_SQRT1_2, util::stod(util::dtoa(M_SQRT1_2)));
|
||||
}
|
||||
Reference in New Issue
Block a user