Group :: Desenvolvimento/C++
RPM: farmhash
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: 61c7939-upstream-namespace-std.patch
Download
Download
From 61c793901edfe06fda675b2765c59bcf036c2b2b Mon Sep 17 00:00:00 2001
From: Carlo Wood <carlo@alinoe.com>
Date: Wed, 29 Aug 2018 10:44:44 +0200
Subject: [PATCH] Avoid 'using namespace std;' as that causes collisions.
In this case, a global variable 'data' collides with std::data.
Besides, it read way better when you can see what IS from the
standard library and what is not.
---
src/farmhash.cc | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/farmhash.cc b/src/farmhash.cc
index 3aa5ce8..b955d30 100644
--- a/src/farmhash.cc
+++ b/src/farmhash.cc
@@ -411,7 +411,6 @@ template <> uint128_t DebugTweak(uint128_t x) {
} // namespace NAMESPACE_FOR_HASH_FUNCTIONS
-using namespace std;
using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
namespace farmhashna {
#undef Fetch
@@ -480,7 +479,7 @@ STATIC_INLINE uint64_t HashLen17to32(const char *s, size_t len) {
// Return a 16-byte hash for 48 bytes. Quick and dirty.
// Callers do best to use "random-looking" values for a and b.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+STATIC_INLINE std::pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
a += w;
b = Rotate(b + a + z, 21);
@@ -488,11 +487,11 @@ STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
a += x;
a += y;
b += Rotate(a, 44);
- return make_pair(a + z, b + c);
+ return std::make_pair(a + z, b + c);
}
// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+STATIC_INLINE std::pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
const char* s, uint64_t a, uint64_t b) {
return WeakHashLen32WithSeeds(Fetch(s),
Fetch(s + 8),
@@ -536,8 +535,8 @@ uint64_t Hash64(const char *s, size_t len) {
uint64_t x = seed;
uint64_t y = seed * k1 + 113;
uint64_t z = ShiftMix(y * k2 + 113) * k2;
- pair<uint64_t, uint64_t> v = make_pair(0, 0);
- pair<uint64_t, uint64_t> w = make_pair(0, 0);
+ std::pair<uint64_t, uint64_t> v = std::make_pair(0, 0);
+ std::pair<uint64_t, uint64_t> w = std::make_pair(0, 0);
x = x * k2 + Fetch(s);
// Set end so that after the loop we have 1 to 64 bytes left to process.
@@ -609,8 +608,8 @@ uint64_t Hash64WithSeeds(const char *s, size_t len,
uint64_t x = seed0;
uint64_t y = seed1 * k2 + 113;
uint64_t z = farmhashna::ShiftMix(y * k2) * k2;
- pair<uint64_t, uint64_t> v = make_pair(seed0, seed1);
- pair<uint64_t, uint64_t> w = make_pair(0, 0);
+ std::pair<uint64_t, uint64_t> v = std::make_pair(seed0, seed1);
+ std::pair<uint64_t, uint64_t> w = std::make_pair(0, 0);
uint64_t u = x - z;
x *= k2;
uint64_t mul = k2 + (u & 0x82);
@@ -1743,7 +1742,7 @@ STATIC_INLINE uint64_t HashLen0to16(const char *s, size_t len) {
// Return a 16-byte hash for 48 bytes. Quick and dirty.
// Callers do best to use "random-looking" values for a and b.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+STATIC_INLINE std::pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
uint64_t w, uint64_t x, uint64_t y, uint64_t z, uint64_t a, uint64_t b) {
a += w;
b = Rotate(b + a + z, 21);
@@ -1751,11 +1750,11 @@ STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
a += x;
a += y;
b += Rotate(a, 44);
- return make_pair(a + z, b + c);
+ return std::make_pair(a + z, b + c);
}
// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
-STATIC_INLINE pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
+STATIC_INLINE std::pair<uint64_t, uint64_t> WeakHashLen32WithSeeds(
const char* s, uint64_t a, uint64_t b) {
return WeakHashLen32WithSeeds(Fetch(s),
Fetch(s + 8),
@@ -1806,7 +1805,7 @@ uint128_t CityHash128WithSeed(const char *s, size_t len, uint128_t seed) {
// We expect len >= 128 to be the common case. Keep 56 bytes of state:
// v, w, x, y, and z.
- pair<uint64_t, uint64_t> v, w;
+ std::pair<uint64_t, uint64_t> v, w;
uint64_t x = Uint128Low64(seed);
uint64_t y = Uint128High64(seed);
uint64_t z = len * k1;