Skip to content

Commit

Permalink
Remove using namespace declaration in folly/Conv.h
Browse files Browse the repository at this point in the history
Summary:
Declaring `using namespace double_conversion;` in a header file is causing ambiguous lookups in a downstream library. Sample failure: https://www.internalfb.com/sandcastle/workflow/4125297258676562026

Switch this function to be explicit instead.

Reviewed By: yfeldblum, hershi

Differential Revision: D66716043

fbshipit-source-id: 3acdfb73c87090cc309d4762dca9dc194261fcff
  • Loading branch information
joachimr2 authored and facebook-github-bot committed Dec 4, 2024
1 parent d2437c1 commit 1a813a9
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions folly/Conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,9 @@ toAppend(
DtoaMode mode,
unsigned int numDigits,
DtoaFlags flags = DtoaFlags::NO_FLAGS) {
using namespace double_conversion;
DoubleToStringConverter::Flags dcFlags = detail::convert(flags);
DoubleToStringConverter conv(
double_conversion::DoubleToStringConverter::Flags dcFlags =
detail::convert(flags);
double_conversion::DoubleToStringConverter conv(
dcFlags,
"Infinity",
"NaN",
Expand All @@ -772,23 +772,24 @@ toAppend(
6, // max leading padding zeros
1); // max trailing padding zeros
char buffer[256];
StringBuilder builder(buffer, sizeof(buffer));
DoubleToStringConverter::DtoaMode dcMode = detail::convert(mode);
double_conversion::StringBuilder builder(buffer, sizeof(buffer));
double_conversion::DoubleToStringConverter::DtoaMode dcMode =
detail::convert(mode);
FOLLY_PUSH_WARNING
FOLLY_CLANG_DISABLE_WARNING("-Wcovered-switch-default")
switch (dcMode) {
case DoubleToStringConverter::SHORTEST:
case double_conversion::DoubleToStringConverter::SHORTEST:
conv.ToShortest(value, &builder);
break;
case DoubleToStringConverter::SHORTEST_SINGLE:
case double_conversion::DoubleToStringConverter::SHORTEST_SINGLE:
conv.ToShortestSingle(static_cast<float>(value), &builder);
break;
case DoubleToStringConverter::FIXED:
case double_conversion::DoubleToStringConverter::FIXED:
conv.ToFixed(value, int(numDigits), &builder);
break;
case DoubleToStringConverter::PRECISION:
case double_conversion::DoubleToStringConverter::PRECISION:
default:
assert(dcMode == DoubleToStringConverter::PRECISION);
assert(dcMode == double_conversion::DoubleToStringConverter::PRECISION);
conv.ToPrecision(value, int(numDigits), &builder);
break;
}
Expand Down

0 comments on commit 1a813a9

Please sign in to comment.