Overview
Comment: | Improve -[hash] for OFNumbers with floats and doubles. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5265f8d08b561f5dfa1a214f74ed3657 |
User & Date: | js on 2010-03-05 00:04:11 |
Other Links: | manifest | tags |
Context
2010-03-05
| ||
03:21 | Let operations on OFNumbers return a new one. check-in: 5e65237276 user: js tags: trunk | |
00:04 | Improve -[hash] for OFNumbers with floats and doubles. check-in: 5265f8d08b user: js tags: trunk | |
2010-03-04
| ||
23:41 | Set version to 0.3-dev. check-in: f11dc7d322 user: js tags: trunk | |
Changes
Modified src/OFNumber.m from [b830cfbb1d] to [7ea4c5f34b].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * the packaging of this file. */ #include "config.h" #import "OFNumber.h" #import "OFExceptions.h" #define RETURN_AS(t) \ switch (type) { \ case OF_NUMBER_CHAR: \ return (t)value.char_; \ case OF_NUMBER_SHORT: \ return (t)value.short_; \ | > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | * the packaging of this file. */ #include "config.h" #import "OFNumber.h" #import "OFExceptions.h" #import "macros.h" #define RETURN_AS(t) \ switch (type) { \ case OF_NUMBER_CHAR: \ return (t)value.char_; \ case OF_NUMBER_SHORT: \ return (t)value.short_; \ |
︙ | ︙ | |||
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 | @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; } } - (uint32_t)hash { return [self asUInt32]; } - add: (OFNumber*)num { CALCULATE2(+=, num) return self; } | > > > > > > > > > > > > > > > > > > > > | 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; } } - (uint32_t)hash { uint32_t hash; size_t i; switch (type) { case OF_NUMBER_FLOAT: OF_HASH_INIT(hash); for (i = 0; i < sizeof(float); i++) OF_HASH_ADD(hash, ((char*)&value.float_)[i]); OF_HASH_FINALIZE(hash); return hash; case OF_NUMBER_DOUBLE: OF_HASH_INIT(hash); for (i = 0; i < sizeof(double); i++) OF_HASH_ADD(hash, ((char*)&value.double_)[i]); OF_HASH_FINALIZE(hash); return hash; default: return [self asUInt32]; } } - add: (OFNumber*)num { CALCULATE2(+=, num) return self; } |
︙ | ︙ |