File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 1313
1414#include " ortools/linear_solver/glop_utils.h"
1515
16+ #include " absl/log/log.h"
17+ #include " ortools/linear_solver/linear_solver.h"
18+ #include " ortools/lp_data/lp_types.h"
19+
1620namespace operations_research {
1721
1822MPSolver::ResultStatus GlopToMPSolverResultStatus (glop::ProblemStatus s) {
Original file line number Diff line number Diff line change @@ -240,18 +240,21 @@ namespace {
240240// - improve performance.
241241// - use vectorized code.
242242namespace internal {
243- uint32_t RawBits (uint32_t x) { return x; } // NOLINT
244- uint32_t RawBits (int x) { return absl::bit_cast<uint32_t >(x); } // NOLINT
245- uint32_t RawBits (float x) { return absl::bit_cast<uint32_t >(x); } // NOLINT
246- uint64_t RawBits (uint64_t x) { return x; } // NOLINT
247- uint64_t RawBits (int64_t x) { return absl::bit_cast<uint64_t >(x); } // NOLINT
248- uint64_t RawBits (double x) { return absl::bit_cast<uint64_t >(x); } // NOLINT
243+ template <typename T>
244+ auto RawBits (T x) {
245+ if constexpr (sizeof (T) == sizeof (uint32_t )) {
246+ return absl::bit_cast<uint32_t >(x);
247+ } else {
248+ static_assert (sizeof (T) == sizeof (uint64_t ));
249+ return absl::bit_cast<uint64_t >(x);
250+ }
251+ }
249252
250253inline uint32_t Bucket (uint32_t x, uint32_t shift, uint32_t radix) {
251254 DCHECK_EQ (0 , radix & (radix - 1 )); // Must be a power of two.
252255 // NOMUTANTS -- a way to compute the remainder of a division when radix is a
253256 // power of two.
254- return (RawBits (x) >> shift) & (radix - 1 );
257+ return (x >> shift) & (radix - 1 );
255258}
256259
257260template <typename T>
You can’t perform that action at this time.
0 commit comments