lawrancej / CompilerKit

Compiler construction library in C.
GNU Lesser General Public License v2.1
55 stars 33 forks source link

Make EmptySet a singleton #28

Closed lawrancej closed 12 years ago

lawrancej commented 12 years ago

EmptySet currently allows multiple instances, which is wasteful of space. We only need one instance of emptyset.

  1. Modify compilerkit_empty_set_new so that it statically allocates a single instance of that object, which it returns.
  2. Modify compilerkit_empty_set_dispose so that it doesn't bother to deallocate the instance.
lapatink commented 12 years ago

I got this one too

lawrancej commented 12 years ago

It works now. I commented on your pull request for a different issue about this. http://blogs.gnome.org/xclaesse/2010/02/11/how-to-make-a-gobject-singleton/

Before closing this issue, I'll need to see: a test in tests/empty-set-test.c to verify when you call compilerkit_empty_set_get_instance twice, the pointers are the same. You're almost done.

lawrancej commented 12 years ago

Hey Kyle, I'll go ahead and write the test case for this. I'm on a test case writing binge at the moment.

lawrancej commented 12 years ago

3e4bc8ef65e35640790fdc347a4 closes this issue.