ObjFW  Diff

Differences From Artifact [0307a15aa9]:

To Artifact [ce3e8ba58d]:

  • File src/OFObject.m — part of check-in [6712442fad] at 2012-12-07 13:57:13 on branch trunk — Revert several OFHashMap related commits.

    This reverts:
    * "Add a per-hashtable seed."
    (cd49c7fcb4b8dca62dccdbf6545d37d86b639eef)
    * "OFMapTable: Reseed on resize."
    (5b545165691cd9ad838c9125b02ff7c857bd4b99)
    * "Add of_random()."
    (9810f191b4e8c1612e7e55095c87e589660fbdba)
    * "OFMapTable: Rotate hash by a random number of bits"
    (3bef412217232d01f202794f7175c130afa1df8f)

    It turned out that these were slowing down all classes based on
    OFHashMap significantly. As there is still no proof that the seeded
    one-at-a-time hash is vulnerable to DoS, these changes were overly
    paranoid. While overly paranoid is usually ok, it is not if it severely
    impacts performance. (user: js, size: 26100) [annotate] [blame] [check-ins using]


225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270

	if OF_UNLIKELY (extra != NULL)
		*extra = (char*)instance + instanceSize + extraAlignment;

	return instance;
}

uint32_t
of_random()
{
#if defined(OF_HAVE_ARC4RANDOM)
	return arc4random();
#elif defined(OF_HAVE_RANDOM)
	static BOOL initialized = NO;

	if (!initialized) {
		struct timeval t;

		gettimeofday(&t, NULL);
		srandom((unsigned)(t.tv_sec ^ t.tv_usec));
		initialized = YES;
	}

	return (uint32_t)((random() << 16) | (random() & 0xFFFF));
#else
	static BOOL initialized = NO;

	if (!initialized) {
		struct timeval t;

		gettimeofday(&t, NULL);
		srand((unsigned)(t.tv_sec ^ t.tv_usec));
		initialized = YES;
	}

	return (rand() << 16) | (rand() & 0xFFFF);
#endif
}

const char*
_NSPrintForDebugger(id object)
{
	return [[object description]
	    cStringWithEncoding: OF_STRING_ENCODING_NATIVE];
}








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







225
226
227
228
229
230
231
































232
233
234
235
236
237
238

	if OF_UNLIKELY (extra != NULL)
		*extra = (char*)instance + instanceSize + extraAlignment;

	return instance;
}

































const char*
_NSPrintForDebugger(id object)
{
	return [[object description]
	    cStringWithEncoding: OF_STRING_ENCODING_NATIVE];
}

307
308
309
310
311
312
313

314











315
316
317
318
319
320
321
		of_pagesize = 4096;
# ifdef _SC_NPROCESSORS_CONF
	if ((of_num_cpus = sysconf(_SC_NPROCESSORS_CONF)) < 1)
# endif
		of_num_cpus = 1;
#endif


	of_hash_seed = of_random();











}

+ (void)initialize
{
}

+ alloc







>
|
>
>
>
>
>
>
>
>
>
>
>







275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
		of_pagesize = 4096;
# ifdef _SC_NPROCESSORS_CONF
	if ((of_num_cpus = sysconf(_SC_NPROCESSORS_CONF)) < 1)
# endif
		of_num_cpus = 1;
#endif

#if defined(OF_HAVE_ARC4RANDOM)
	of_hash_seed = arc4random();
#elif defined(OF_HAVE_RANDOM)
	struct timeval t;
	gettimeofday(&t, NULL);
	srandom((unsigned)(t.tv_sec ^ t.tv_usec));
	of_hash_seed = (uint32_t)((random() << 16) | (random() & 0xFFFF));
#else
	struct timeval t;
	gettimeofday(&t, NULL);
	srand((unsigned)(t.tv_sec ^ t.tv_usec));
	of_hash_seed = (uint32_t)((rand() << 16) | (rand() & 0xFFFF));
#endif
}

+ (void)initialize
{
}

+ alloc