/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2011-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <typeinfo>
#include <utility>
-#include <boost/implicit_cast.hpp>
#include <double-conversion/double-conversion.h> // V8 JavaScript implementation
#include <folly/Demangle.h>
};
// "count leading zeroes" operation not valid; for 0; special case this.
- if UNLIKELY (! v) {
+ if (UNLIKELY(!v)) {
return 1;
}
// return that log_10 lower bound, plus adjust if input >= 10^(that bound)
// in case there's a small error and we misjudged length.
- return minLength + (uint32_t) (UNLIKELY (v >= powersOf10[minLength]));
+ return minLength + uint32_t(v >= powersOf10[minLength]);
#else
uint32_t result = 1;
- for (;;) {
- if (LIKELY(v < 10)) return result;
- if (LIKELY(v < 100)) return result + 1;
- if (LIKELY(v < 1000)) return result + 2;
- if (LIKELY(v < 10000)) return result + 3;
+ while (true) {
+ if (LIKELY(v < 10)) {
+ return result;
+ }
+ if (LIKELY(v < 100)) {
+ return result + 1;
+ }
+ if (LIKELY(v < 1000)) {
+ return result + 2;
+ }
+ if (LIKELY(v < 10000)) {
+ return result + 3;
+ }
// Skip ahead by 4 orders of magnitude
v /= 10000U;
result += 4;