Overview
Comment: | Make hashes independant of endianess in OF{Float,Double}{Vector,Matrix}.
Also removes unnecessary OF_HASH_ADD_INT* macros (except |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f3db07447850f42b5f6d9c9d057900a0 |
User & Date: | js on 2011-09-17 19:18:09 |
Other Links: | manifest | tags |
Context
2011-09-17
| ||
20:17 | Remove +[OFThread sleepForTimeInterval:microseconds:]. check-in: c19b2b5726 user: js tags: trunk | |
19:18 | Make hashes independant of endianess in OF{Float,Double}{Vector,Matrix}. check-in: f3db074478 user: js tags: trunk | |
18:58 | Better format for serialization of floating point OFNumbers. check-in: ef02147e8b user: js tags: trunk | |
Changes
Modified src/OFDoubleMatrix.m from [a2ea99d71f] to [8e0af9d60e].
︙ | ︙ | |||
220 221 222 223 224 225 226 | size_t i; uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < rows * columns; i++) { union { | | | > | > | | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | size_t i; uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < rows * columns; i++) { union { double d; uint8_t b[sizeof(double)]; } u; uint8_t j; u.d = of_bswap_double_if_be(data[i]); for (j = 0; j < sizeof(double); j++) OF_HASH_ADD(hash, u.b[j]); } OF_HASH_FINALIZE(hash); return hash; } |
︙ | ︙ |
Modified src/OFDoubleVector.m from [8de83ff694] to [3c930c2cbc].
︙ | ︙ | |||
207 208 209 210 211 212 213 | size_t i; uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < dimension; i++) { union { | | | > | > | | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | size_t i; uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < dimension; i++) { union { double d; uint8_t b[sizeof(double)]; } u; uint8_t j; u.d = of_bswap_double_if_be(data[i]); for (j = 0; j < sizeof(double); j++) OF_HASH_ADD(hash, u.b[j]); } OF_HASH_FINALIZE(hash); return hash; } |
︙ | ︙ |
Modified src/OFFloatMatrix.m from [d289104dc5] to [0e7f420221].
︙ | ︙ | |||
221 222 223 224 225 226 227 | uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < rows * columns; i++) { union { float f; | | > | > | | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < rows * columns; i++) { union { float f; uint8_t b[sizeof(float)]; } u; uint8_t j; u.f = of_bswap_float_if_be(data[i]); for (j = 0; j < sizeof(float); j++) OF_HASH_ADD(hash, u.b[j]); } OF_HASH_FINALIZE(hash); return hash; } |
︙ | ︙ |
Modified src/OFFloatVector.m from [ac31706dc3] to [ca289ecb6a].
︙ | ︙ | |||
208 209 210 211 212 213 214 | uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < dimension; i++) { union { float f; | | > | > | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < dimension; i++) { union { float f; uint8_t b[sizeof(float)]; } u; uint8_t j; u.f = of_bswap_float_if_be(data[i]); for (j = 0; j < sizeof(float); j++) OF_HASH_ADD(hash, u.b[j]); } OF_HASH_FINALIZE(hash); return hash; } |
︙ | ︙ |
Modified src/OFURL.m from [8b92d8f389] to [9e5eb723f2].
︙ | ︙ | |||
361 362 363 364 365 366 367 | - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); | | | > | | | | | | | | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, [scheme hash]); OF_HASH_ADD_HASH(hash, [host hash]); OF_HASH_ADD(hash, (port & 0xFF00) >> 8); OF_HASH_ADD(hash, port & 0xFF); OF_HASH_ADD_HASH(hash, [user hash]); OF_HASH_ADD_HASH(hash, [password hash]); OF_HASH_ADD_HASH(hash, [path hash]); OF_HASH_ADD_HASH(hash, [parameters hash]); OF_HASH_ADD_HASH(hash, [query hash]); OF_HASH_ADD_HASH(hash, [fragment hash]); OF_HASH_FINALIZE(hash); return hash; } - copy |
︙ | ︙ |
Modified src/OFXMLAttribute.m from [72bfa63edb] to [d248ebf982].
︙ | ︙ | |||
147 148 149 150 151 152 153 | - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); | | | | | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, [name hash]); OF_HASH_ADD_HASH(hash, [ns hash]); OF_HASH_ADD_HASH(hash, [stringValue hash]); OF_HASH_FINALIZE(hash); return hash; } - (OFXMLElement*)XMLElementBySerializing |
︙ | ︙ |
Modified src/OFXMLElement.m from [567535af96] to [8a9ce6afef].
︙ | ︙ | |||
1149 1150 1151 1152 1153 1154 1155 | - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); | | | | | | | | | | | 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 | - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD_HASH(hash, [name hash]); OF_HASH_ADD_HASH(hash, [ns hash]); OF_HASH_ADD_HASH(hash, [defaultNamespace hash]); OF_HASH_ADD_HASH(hash, [attributes hash]); OF_HASH_ADD_HASH(hash, [namespaces hash]); OF_HASH_ADD_HASH(hash, [children hash]); OF_HASH_ADD_HASH(hash, [characters hash]); OF_HASH_ADD_HASH(hash, [CDATA hash]); OF_HASH_ADD_HASH(hash, [comment hash]); OF_HASH_FINALIZE(hash); return hash; } - copy |
︙ | ︙ |
Modified src/macros.h from [d6db7501d8] to [fee9f03105].
︙ | ︙ | |||
319 320 321 322 323 324 325 | } #define OF_HASH_FINALIZE(hash) \ { \ hash += (hash << 3); \ hash ^= (hash >> 11); \ hash += (hash << 15); \ } | | < < < < < < | | | | | < < < < < < < < < < < < | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | } #define OF_HASH_FINALIZE(hash) \ { \ hash += (hash << 3); \ hash ^= (hash >> 11); \ hash += (hash << 15); \ } #define OF_HASH_ADD_HASH(hash, other) \ { \ uint32_t otherCopy = other; \ OF_HASH_ADD(hash, (otherCopy >> 24) & 0xFF); \ OF_HASH_ADD(hash, (otherCopy >> 16) & 0xFF); \ OF_HASH_ADD(hash, (otherCopy >> 8) & 0xFF); \ OF_HASH_ADD(hash, otherCopy & 0xFF); \ } static OF_INLINE of_range_t of_range(size_t start, size_t length) { of_range_t range = { start, length }; |
︙ | ︙ |