diff --git a/ydb/library/yql/utils/parse_double.cpp b/ydb/library/yql/utils/parse_double.cpp index 0c06ad95447b..90923160c552 100644 --- a/ydb/library/yql/utils/parse_double.cpp +++ b/ydb/library/yql/utils/parse_double.cpp @@ -9,32 +9,38 @@ namespace { template bool GenericTryFloatFromString(TStringBuf buf, T& value) { value = 0; - if (!buf.size() || !TryFromString(buf.data(), buf.size(), value)) { - const char* ptr = buf.data(); - ui32 size = buf.size(); - char sign = '+'; - if (*ptr == '+' || *ptr == '-') { - sign = *ptr; - ++ptr; - --size; - } + if (!buf.size()) { + return false; + } + + if (TryFromString(buf.data(), buf.size(), value)) { + return true; + } + + const char* ptr = buf.data(); + ui32 size = buf.size(); + char sign = '+'; + if (*ptr == '+' || *ptr == '-') { + sign = *ptr; + ++ptr; + --size; + } - if (size != 3) { - return false; - } + if (size != 3) { + return false; + } - // NaN or Inf (ignoring case) - if (AsciiToUpper(ptr[0]) == 'N' && AsciiToUpper(ptr[1]) == 'A' && AsciiToUpper(ptr[2]) == 'N') { - value = std::numeric_limits::quiet_NaN(); - } else if (AsciiToUpper(ptr[0]) == 'I' && AsciiToUpper(ptr[1]) == 'N' && AsciiToUpper(ptr[2]) == 'F') { - value = std::numeric_limits::infinity(); - } else { - return false; - } + // NaN or Inf (ignoring case) + if (AsciiToUpper(ptr[0]) == 'N' && AsciiToUpper(ptr[1]) == 'A' && AsciiToUpper(ptr[2]) == 'N') { + value = std::numeric_limits::quiet_NaN(); + } else if (AsciiToUpper(ptr[0]) == 'I' && AsciiToUpper(ptr[1]) == 'N' && AsciiToUpper(ptr[2]) == 'F') { + value = std::numeric_limits::infinity(); + } else { + return false; + } - if (sign == '-') { - value = -value; - } + if (sign == '-') { + value = -value; } return true;