aboutsummaryrefslogtreecommitdiffstats
path: root/util/string
diff options
context:
space:
mode:
authorAlexander Gololobov <davenger@yandex-team.com>2022-02-10 16:47:37 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:37 +0300
commit39608cdb86363c75ce55b2b9a69841c3b71f22cf (patch)
tree4ec132c1665bd4d68e3628aa18d937c70d32413b /util/string
parent54295b9bd4dc45c54d804084fd846d945148a7f0 (diff)
downloadydb-39608cdb86363c75ce55b2b9a69841c3b71f22cf.tar.gz
Restoring authorship annotation for Alexander Gololobov <davenger@yandex-team.com>. Commit 1 of 2.
Diffstat (limited to 'util/string')
-rw-r--r--util/string/cast.cpp22
-rw-r--r--util/string/cast_ut.cpp6
2 files changed, 14 insertions, 14 deletions
diff --git a/util/string/cast.cpp b/util/string/cast.cpp
index aa1e65a8e9..8c40983c84 100644
--- a/util/string/cast.cpp
+++ b/util/string/cast.cpp
@@ -640,9 +640,9 @@ DEF_FLT_SPEC(long double)
#undef DEF_FLT_SPEC
-// Using StrToD for float and double because it is faster than sscanf.
+// Using StrToD for float and double because it is faster than sscanf.
// Exception-free, specialized for float types
-template <>
+template <>
bool TryFromStringImpl<double>(const char* data, size_t len, double& result) {
if (!len) {
return false;
@@ -680,19 +680,19 @@ bool TryFromStringImpl<long double>(const char* data, size_t len, long double& r
// Exception-throwing, specialized for float types
template <>
-double FromStringImpl<double>(const char* data, size_t len) {
+double FromStringImpl<double>(const char* data, size_t len) {
double d = 0.0;
if (!TryFromStringImpl(data, len, d)) {
ythrow TFromStringException() << TStringBuf("cannot parse float(") << TStringBuf(data, len) << TStringBuf(")");
- }
- return d;
-}
-
-template <>
-float FromStringImpl<float>(const char* data, size_t len) {
+ }
+ return d;
+}
+
+template <>
+float FromStringImpl<float>(const char* data, size_t len) {
return static_cast<float>(FromStringImpl<double>(data, len));
-}
-
+}
+
double StrToD(const char* b, const char* e, char** se) {
struct TCvt: public StringToDoubleConverter {
inline TCvt()
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index 033450c38c..7f54dcde32 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -163,7 +163,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
f = FromString<TFloat>(str);
UNIT_ASSERT_DOUBLES_EQUAL(f, canonValue, eps);
}
-
+
template <class TFloat>
void BadFloatTester(const char* str) {
const double eps = 10E-5;
@@ -175,7 +175,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_EXCEPTION(f = FromString<TFloat>(str), TFromStringException);
Y_UNUSED(f); // shut up compiler about 'assigned value that is not used'
}
-
+
Y_UNIT_TEST(TestToFrom) {
test1(bool, true);
test1(bool, false);
@@ -315,7 +315,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
BadFloatTester<long double>("10e 2");
BadFloatTester<long double>(""); // IGNIETFERRO-300
}
-
+
Y_UNIT_TEST(TestLiteral) {
UNIT_ASSERT_VALUES_EQUAL(ToString("abc"), TString("abc"));
}