Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 226815 - Support packing enum-valued features into bit flags
Summary: Support packing enum-valued features into bit flags
Status: VERIFIED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: Tools (show other bugs)
Version: 2.4.0   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Dave Steinberg CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 204200
  Show dependency tree
 
Reported: 2008-04-12 14:49 EDT by Ed Merks CLA
Modified: 2008-04-21 12:15 EDT (History)
3 users (show)

See Also:


Attachments
Patches to support GenModel.packedEnums (428.89 KB, patch)
2008-04-12 14:51 EDT, Ed Merks CLA
no flags Details | Diff
Better handling of straddling condition (428.87 KB, patch)
2008-04-12 14:55 EDT, Ed Merks CLA
no flags Details | Diff
Sample project for testing (27.43 KB, application/octet-stream)
2008-04-12 14:56 EDT, Ed Merks CLA
no flags Details
Updated patch against latest version of head. (445.61 KB, patch)
2008-04-15 08:45 EDT, Ed Merks CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Merks CLA 2008-04-12 14:49:21 EDT
Just as with booleans, the values of an enum could benefit from packing them into bit flags.
Comment 1 Ed Merks CLA 2008-04-12 14:51:49 EDT
Created attachment 95812 [details]
Patches to support GenModel.packedEnums
Comment 2 Ed Merks CLA 2008-04-12 14:55:47 EDT
Created attachment 95813 [details]
Better handling of straddling condition
Comment 3 Ed Merks CLA 2008-04-12 14:56:50 EDT
Created attachment 95814 [details]
Sample project for testing
Comment 4 Ed Merks CLA 2008-04-12 14:57:30 EDT
Dave, here's the packed enum thing we talked about.
Comment 5 Ed Merks CLA 2008-04-15 08:45:15 EDT
Created attachment 96060 [details]
Updated patch against latest version of head.

Dave, the only other things I was thinking I would add is instead of doing EnumType.values()[ordinal] or (EnumType)EnumType.VALUES.get(ordinal) store the typed array in a private field and use that.  This avoids method calls (likely EnumType.values() creates a new array) and casting, in the case of Java 1.4.
Comment 6 Dave Steinberg CLA 2008-04-17 16:40:39 EDT
The computation of flag sizes was a little bit generous (allocating an extra bit in some cases), so I fixed that.  I also improved the flag mask computation and moved it into GenClass, where it's much more readable.

The enhancement is committed to CVS for EMF 2.4.
Comment 7 Nick Boldt CLA 2008-04-20 02:44:34 EDT
Fix available in HEAD: Alyssa (I200804200420).