MinecraftForge / ForgeFlower

Forge's modifications to FernFlower. Fixing various bugs/inconsistencies. Main Repo: https://github.com/MinecraftForge/FernFlower
Apache License 2.0
80 stars 44 forks source link

Add support for switch on string #83

Closed ichttt closed 4 years ago

ichttt commented 4 years ago

See DimensionGeneratorSettings for an example, which currently looks like this:

      switch(s4.hashCode()) {
      case -1100099890:
         if (s4.equals("largebiomes")) {
            b0 = 3;
         }
         break;
      case 3145593:
         if (s4.equals("flat")) {
            b0 = 0;
         }
         break;
      case 1045526590:
         if (s4.equals("debug_all_block_states")) {
            b0 = 1;
         }
         break;
      case 1271599715:
         if (s4.equals("amplified")) {
            b0 = 2;
         }
      }

      switch(b0) {

The whole upper switch can be removed, and the lower switch should switch on the string.

Mysterious-Dev commented 4 years ago

The problem is that it affects the operation of Native Java and not the Forge API

covers1624 commented 4 years ago

What? This is clearly a decompiler artifact. This isn't Forge.. This issue tracker is for Decompiler artifacts.

LexManos commented 4 years ago

Yes, cleaning up string switches like we do enum switches would be nice. Just not something i've looked into. Looks like a simple pattern tho, two switched, 1st over var.hashCode with all cases setting var2. Then 2nd immediately after being over var2.

JDLogic commented 4 years ago

Added in 5132d2b6fe04a661ffa2d84df53a25ab13e78e62