On 17-Apr-10, at 7:04 PM, Kyle Sluder wrote:

On Sat, Apr 17, 2010 at 2:01 PM, Charles Srstka
<cocoa...@charlessoft.com> wrote:
How about just giving your object only one instance variable, which is a pointer to a C struct, with all the object’s accessor methods pointing to elements in the struct? Then, all you’d have to do would be to swap out the struct for another one, or zero the struct. No runtime hacking, no assumptions about the internals of the object format.

And if allocation of *that* struct becomes a performance problem, swap
in a new allocator like jemalloc. I recently read something about
Blender enjoying a startling performance improvement by switching to
jemalloc, because they malloc and free tons of small structs.

I don't think I'm crazy about this. There are many different subclasses, so each subclass would have its own corresponding struct, and every ivar access would go through an indirection; it sounds very confusing and messy. Not to say there might not be cases where it would be the correct design; but for my situation, I think I'm happier with my current design. Thanks for the suggestion, though!

Ben Haller
McGill University


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to