Advertisement
Guest User

Untitled

a guest
Mar 12th, 2014
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. Ew, no no no. This will return the same thing every time, so this code should be moved to a static initialization block, where it caches the method names in a final String array.
  2.  
  3. private static final computerMethodNames;
  4. static {
  5. computerMethodNames = new String[ComputerMethod.values().length];
  6. // fill in method names here, as you've done
  7. }
  8.  
  9. Like that.
  10.  
  11.  
  12.  
  13. #2
  14.  
  15.  
  16. I'm not super familiar with OpenComputers, so is there a good reason this doesn't return the same thing as CC's getType()? Is this a community naming convention at work?
  17.  
  18.  
  19.  
  20. #3
  21. BigRenegade/BigReactors
  22.  
  23. Linear-time lookup is ugly, but the Array conversion is much worse. Place the java.util.Arrays.asList() call into a static initializer and cache the results in a static final variable, please.
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement