ObjFW  Diff

Differences From Artifact [14bd700788]:

  • File src/OFAutoreleasePool.m — part of check-in [f92e1c77a0] at 2010-07-08 09:20:54 on branch trunk — Optimize OFAutoreleasePool.

    It always allocates memory for 16 objects now. releaseObjects does not
    free the memory allocated to store objects so that the same number of
    objects can be stored in the autorelease pool again without the need to
    allocate memory. This will give loops creating lots of objects a huge
    performance boost. (user: js, size: 3837) [annotate] [blame] [check-ins using]

To Artifact [0e3d14e495]:


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
		return;

	if (!of_tlskey_new(&first_key) || !of_tlskey_new(&last_key))
		@throw [OFInitializationFailedException newWithClass: self];
}
#endif

+ (void)addObjectToTopmostPool: (OFObject*)obj
{
#ifdef OF_THREADS
	id last = of_tlskey_get(last_key);
#endif

	if (last == nil) {
		@try {







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
		return;

	if (!of_tlskey_new(&first_key) || !of_tlskey_new(&last_key))
		@throw [OFInitializationFailedException newWithClass: self];
}
#endif

+ (void)addObjectToTopmostPool: (id)obj
{
#ifdef OF_THREADS
	id last = of_tlskey_get(last_key);
#endif

	if (last == nil) {
		@try {
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
		[self dealloc];
		@throw e;
	}

	return self;
}

- (void)addObject: (OFObject*)obj
{
	if (count + 1 > size) {
		objects = [self resizeMemory: objects
				    toNItems: size + GROW_SIZE
				    withSize: sizeof(id)];
		size += GROW_SIZE;
	}







|







129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
		[self dealloc];
		@throw e;
	}

	return self;
}

- (void)addObject: (id)obj
{
	if (count + 1 > size) {
		objects = [self resizeMemory: objects
				    toNItems: size + GROW_SIZE
				    withSize: sizeof(id)];
		size += GROW_SIZE;
	}