Skip to content

Commit 2ebd404

Browse files
authored
Small fixes (#4957)
1 parent 00b7dec commit 2ebd404

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

ortools/linear_solver/glop_utils.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
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+
1620
namespace operations_research {
1721

1822
MPSolver::ResultStatus GlopToMPSolverResultStatus(glop::ProblemStatus s) {

ortools/set_cover/set_cover_heuristics.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,21 @@ namespace {
240240
// - improve performance.
241241
// - use vectorized code.
242242
namespace 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

250253
inline 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

257260
template <typename T>

0 commit comments

Comments
 (0)