Task #387

avatar

Use own hashing algorithm for nick colors

Added by Mirco Bauer 5273 days ago. Updated 5212 days ago.

Status:Closed Start:06/14/2010
Priority:Normal Due date:
Assigned to:avatarMirco Bauer % Done:

100%

Category:Engine
Target version:0.8
Complexity:

Medium

Votes: 0

Description

Currently Smuxi relies on the String.GetHashCode() implementation of the runtime. This has the drawback that the value could change over time (between runtime versions and implementations) leading to suddenly different colors. Thus Smuxi should use an own algorithm to guarantee the same nick colors over time. See ProtocolManagerBase.GetIdentityNameColor()

Associated revisions

Revision 94f5be71e7e39a9028e9877f967fa65e770b5d95
Added by Mirco Bauer 5212 days ago

Implemented new message builder API

Implemented a new message builder API which allows to create messages with
a much nicer API and using less code.

The new API generates more distinct nick-colors by using a color combination
consisting of colored tags (<>) and colored nick name. (closes: #388)
The own nick is now bold to make it more distinct from other nick names.
(closes: #419)

Refactored Engine-IRC and Engine-Twitter to make use of the new API.

Imported MIT/X11 licensed CRC32 implementation for stable hashcodes needed for
the unique nick-colors feature. (closes: #387)

History

Updated by Mirco Bauer 5261 days ago

avatar
  • Target version changed from 0.7.2 to 0.8
  • Complexity changed from Low to Medium

This is not as simple as it might sound like. Mono's String.GetHashCode() implementation uses unsafe code and the CRC32 is not as trivial as assumed. So a custom algorithm has to be written.

Updated by Clément Bourgeois 5225 days ago

avatar

Mirco Bauer wrote:

This is not as simple as it might sound like. Mono's String.GetHashCode() implementation uses unsafe code and the CRC32 is not as trivial as assumed. So a custom algorithm has to be written.

You could use something standard like SHA1 or MD5 to achieve this simply.

Updated by Mirco Bauer 5225 days ago

avatar

MD5 uses 128 bits which is 4 times the size of CRC32 that uses 32 bits. Currently the nick colors uses 3 x 8 bits. Without caching this could be a bit expensive, but probably still better than a custom algorithm. Caching 2000 different nickname hashes would be 32MB of memory though, which is a lot.

Updated by Mirco Bauer 5212 days ago

avatar
  • Status changed from New to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF