mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Turned Richards specific hash method into a generic one.
--- -- M Source/NSColor.m M ChangeLog git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28812 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
417d856f20
commit
72ea926da9
2 changed files with 23 additions and 18 deletions
|
@ -1,3 +1,8 @@
|
|||
2009-10-12 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSColor.m (-hash): Turned Richards specific hash method
|
||||
into a generic one.
|
||||
|
||||
2009-10-12 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSColor.m: Remove special proxy handling introduced in
|
||||
|
|
|
@ -1219,6 +1219,24 @@ systemColorWithName(NSString *name)
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (NSUInteger) hash
|
||||
{
|
||||
int nums = [self numberOfComponents];
|
||||
union {
|
||||
uint8_t bytes[sizeof(float) * nums];
|
||||
float floats[nums];
|
||||
} u;
|
||||
NSUInteger h = 0;
|
||||
unsigned i;
|
||||
|
||||
[self getComponents: u.floats];
|
||||
for (i = 0; i < sizeof(u); i++)
|
||||
{
|
||||
h = (h << 5) + h + u.bytes[i];
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
- (int) numberOfComponents
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
|
@ -2037,24 +2055,6 @@ static NSRecursiveLock *namedColorLock = nil;
|
|||
*alpha = _alpha_component;
|
||||
}
|
||||
|
||||
- (NSUInteger) hash
|
||||
{
|
||||
union {
|
||||
uint8_t bytes[sizeof(float)*2];
|
||||
float floats[2];
|
||||
} u;
|
||||
NSUInteger h = 0;
|
||||
unsigned i;
|
||||
|
||||
u.floats[0] = _white_component;
|
||||
u.floats[1] = _alpha_component;
|
||||
for (i = 0; i < sizeof(u); i++)
|
||||
{
|
||||
h = (h << 5) + h + u.bytes[i];
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
- (BOOL) isEqual: (id)other
|
||||
{
|
||||
if (other == self)
|
||||
|
|
Loading…
Reference in a new issue