From 4e2fb455763206542874d1853dcfcfedf5ca94d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Aug 2012 10:03:17 +0000 Subject: style cleanup --- intern/string/STR_HashedString.h | 82 +++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 43 deletions(-) (limited to 'intern') diff --git a/intern/string/STR_HashedString.h b/intern/string/STR_HashedString.h index f56e365bdb3..8bfbde65895 100644 --- a/intern/string/STR_HashedString.h +++ b/intern/string/STR_HashedString.h @@ -27,14 +27,10 @@ /** \file string/STR_HashedString.h * \ingroup string - */ - - -/** - + * * Copyright (C) 2001 NaN Technologies B.V. * This file was formerly known as: GEN_StdString.cpp. - * @date November, 14, 2001 + * \date November, 14, 2001 */ #ifndef __STR_HASHEDSTRING_H__ @@ -53,22 +49,22 @@ // static inline void STR_gHashMix(dword& a, dword& b, dword& c) { - a -= b; a -= c; a ^= (c>>13); - b -= c; b -= a; b ^= (a<<8); - c -= a; c -= b; c ^= (b>>13); - a -= b; a -= c; a ^= (c>>12); - b -= c; b -= a; b ^= (a<<16); - c -= a; c -= b; c ^= (b>>5); - a -= b; a -= c; a ^= (c>>3); - b -= c; b -= a; b ^= (a<<10); - c -= a; c -= b; c ^= (b>>15); + a -= b; a -= c; a ^= (c >> 13); + b -= c; b -= a; b ^= (a << 8); + c -= a; c -= b; c ^= (b >> 13); + a -= b; a -= c; a ^= (c >> 12); + b -= c; b -= a; b ^= (a << 16); + c -= a; c -= b; c ^= (b >> 5); + a -= b; a -= c; a ^= (c >> 3); + b -= c; b -= a; b ^= (a << 10); + c -= a; c -= b; c ^= (b >> 15); } // // Fast Hashable functionality // http://www.concentric.net/~Ttwang/tech/inthash.htm // -static inline dword STR_gHash(dword inDWord) +static inline dword STR_gHash(dword inDWord) { dword key = inDWord; key += ~(key << 16); @@ -80,43 +76,43 @@ static inline dword STR_gHash(dword inDWord) return key; } -enum { GOLDEN_RATIO = 0x9e3779b9 }; // arbitrary value to initialize hash funtion, well not so arbitrary - // as this value is taken from the pigs library (Orange Games/Lost Boys) +enum { GOLDEN_RATIO = 0x9e3779b9 }; /* arbitrary value to initialize hash funtion, well not so arbitrary + * as this value is taken from the pigs library (Orange Games/Lost Boys) */ -static dword STR_gHash(const void* in, int len, dword init_val) +static dword STR_gHash(const void *in, int len, dword init_val) { - unsigned int length = len; + unsigned int length = len; dword a = (dword)GOLDEN_RATIO; dword b = (dword)GOLDEN_RATIO; - dword c = init_val; // the previous hash value + dword c = init_val; /* the previous hash value */ byte *p_in = (byte *)in; // Do the largest part of the key while (length >= 12) { - a += (p_in[0] + ((dword)p_in[1]<<8) + ((dword)p_in[2] <<16) + ((dword)p_in[3] <<24)); - b += (p_in[4] + ((dword)p_in[5]<<8) + ((dword)p_in[6] <<16) + ((dword)p_in[7] <<24)); - c += (p_in[8] + ((dword)p_in[9]<<8) + ((dword)p_in[10]<<16) + ((dword)p_in[11]<<24)); + a += (p_in[0] + ((dword)p_in[1] << 8) + ((dword)p_in[2] << 16) + ((dword)p_in[3] << 24)); + b += (p_in[4] + ((dword)p_in[5] << 8) + ((dword)p_in[6] << 16) + ((dword)p_in[7] << 24)); + c += (p_in[8] + ((dword)p_in[9] << 8) + ((dword)p_in[10] << 16) + ((dword)p_in[11] << 24)); STR_gHashMix(a, b, c); p_in += 12; length -= 12; } // Handle the last 11 bytes c += len; - switch(length) { - case 11: c+=((dword)p_in[10]<<24); - case 10: c+=((dword)p_in[9]<<16); - case 9 : c+=((dword)p_in[8]<<8); // the first byte of c is reserved for the length - case 8 : b+=((dword)p_in[7]<<24); - case 7 : b+=((dword)p_in[6]<<16); - case 6 : b+=((dword)p_in[5]<<8); - case 5 : b+=p_in[4]; - case 4 : a+=((dword)p_in[3]<<24); - case 3 : a+=((dword)p_in[2]<<16); - case 2 : a+=((dword)p_in[1]<<8); - case 1 : a+=p_in[0]; + switch (length) { + case 11: c += ((dword)p_in[10] << 24); + case 10: c += ((dword)p_in[9] << 16); + case 9: c += ((dword)p_in[8] << 8); /* the first byte of c is reserved for the length */ + case 8: b += ((dword)p_in[7] << 24); + case 7: b += ((dword)p_in[6] << 16); + case 6: b += ((dword)p_in[5] << 8); + case 5: b += p_in[4]; + case 4: a += ((dword)p_in[3] << 24); + case 3: a += ((dword)p_in[2] << 16); + case 2: a += ((dword)p_in[1] << 8); + case 1: a += p_in[0]; } STR_gHashMix(a, b, c); @@ -129,18 +125,18 @@ static dword STR_gHash(const void* in, int len, dword init_val) class STR_HashedString : public STR_String { public: - STR_HashedString() : STR_String(),m_Hashed(false) {} - STR_HashedString(const char* str) : STR_String(str),m_Hashed(false) {} - STR_HashedString(const STR_String& str) : STR_String(str),m_Hashed(false) {} + STR_HashedString() : STR_String(), m_Hashed(false) {} + STR_HashedString(const char *str) : STR_String(str), m_Hashed(false) {} + STR_HashedString(const STR_String &str) : STR_String(str), m_Hashed(false) {} - inline dword hash(dword init=0) const + inline dword hash(dword init = 0) const { if (!m_Hashed) { - const char* str = *this; + const char *str = *this; int length = this->Length(); - m_CachedHash = STR_gHash(str,length,init); - m_Hashed=true; + m_CachedHash = STR_gHash(str, length, init); + m_Hashed = true; } return m_CachedHash; } -- cgit v1.2.3