style cleanup

This commit is contained in:
Campbell Barton
2012-08-06 10:03:17 +00:00
parent 3b743582ec
commit 4e2fb45576
2 changed files with 41 additions and 45 deletions

View File

@@ -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<int32> 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;
}

View File

@@ -1443,13 +1443,13 @@ void BKE_node_clipboard_clear(void)
bNode *node, *node_next;
bNodeLink *link, *link_next;
for (link = node_clipboard.links.first; link; link=link_next) {
for (link = node_clipboard.links.first; link; link = link_next) {
link_next = link->next;
nodeRemLink(NULL, link);
}
node_clipboard.links.first = node_clipboard.links.last = NULL;
for (node = node_clipboard.nodes.first; node; node=node_next) {
for (node = node_clipboard.nodes.first; node; node = node_next) {
node_next = node->next;
nodeFreeNode(NULL, node);
}