[jboss-jira] [JBoss JIRA] (WFLY-1415) Move away from expensive enum switch

Chris Kujawa (JIRA) issues at jboss.org
Wed Jul 2 06:36:24 EDT 2014


    [ https://issues.jboss.org/browse/WFLY-1415?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981329#comment-12981329 ] 

Chris Kujawa commented on WFLY-1415:
------------------------------------

I'd like to take a look at this one, but I want to make sure I fully understand what's being asked for first.

Is the approach of grabbing the name of the enum being used at the top then comparing to String constants acceptable...something like this:

public static final String COOKIE_MODE = "COOKIE";
...
 for (SessionTrackingModeType mode : modes) {
                        String mode_string = mode.name();
                        switch (mode_string) {
                            case COOKIE_MODE:
                                trackingModes.add(SessionTrackingMode.COOKIE);
                                break;
...

 or are you actually looking to replace the enums altogether?

BTW, I apologize for the formatting...tried to add <code> tags to the above block and they didn't seem to have an affect.

> Move away from expensive enum switch
> ------------------------------------
>
>                 Key: WFLY-1415
>                 URL: https://issues.jboss.org/browse/WFLY-1415
>             Project: WildFly
>          Issue Type: Task
>      Security Level: Public(Everyone can see) 
>            Reporter: David Lloyd
>            Priority: Minor
>              Labels: janitor
>             Fix For: 9.0.0.CR1
>
>
> We use enums and enum switch extensively.  These constructs generate many, many additional classes and bloat the code base unnecessarily.
> All cases where we are using enum-based switches for our XML parsers should be converted to use Java 7 String switch instead.  The enum values shall be replaced with String constant fields, all enum switches converted to String switches, and all enum types removed from these classes.  The net result should be a reduction by dozens if not hundreds of .class files, and possibly a measurable performance boost as well.



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)


More information about the jboss-jira mailing list