Skip to content

Commit

Permalink
constinit -> constexpr for DisplayUnits
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 674283690
Change-Id: I5ff9fd54af1175c2eb71fb942f10834f7be6bf9f
  • Loading branch information
Abseil Team authored and copybara-github committed Sep 13, 2024
1 parent f555f69 commit f7c22f5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions absl/time/duration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,12 @@ struct DisplayUnit {
int prec;
double pow10;
};
ABSL_CONST_INIT const DisplayUnit kDisplayNano = {"ns", 2, 1e2};
ABSL_CONST_INIT const DisplayUnit kDisplayMicro = {"us", 5, 1e5};
ABSL_CONST_INIT const DisplayUnit kDisplayMilli = {"ms", 8, 1e8};
ABSL_CONST_INIT const DisplayUnit kDisplaySec = {"s", 11, 1e11};
ABSL_CONST_INIT const DisplayUnit kDisplayMin = {"m", -1, 0.0}; // prec ignored
ABSL_CONST_INIT const DisplayUnit kDisplayHour = {"h", -1,
0.0}; // prec ignored
constexpr DisplayUnit kDisplayNano = {"ns", 2, 1e2};
constexpr DisplayUnit kDisplayMicro = {"us", 5, 1e5};
constexpr DisplayUnit kDisplayMilli = {"ms", 8, 1e8};
constexpr DisplayUnit kDisplaySec = {"s", 11, 1e11};
constexpr DisplayUnit kDisplayMin = {"m", -1, 0.0}; // prec ignored
constexpr DisplayUnit kDisplayHour = {"h", -1, 0.0}; // prec ignored

void AppendNumberUnit(std::string* out, int64_t n, DisplayUnit unit) {
char buf[sizeof("2562047788015216")]; // hours in max duration
Expand Down

0 comments on commit f7c22f5

Please sign in to comment.