Solved Small question about java :)

Discussion in 'Plugin Development' started by bfgbfggf, Jul 7, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    bfgbfggf

    is better if I use:
    Code:java
    1.  
    2. if (event.getPlayer().hasPermission("Plugin.Node")){
    3. Player player = event.getPlayer();
    4. //Code where I use "player"
    5. } else {
    6. //Other code where I don't use Player, or just end of code
    7. }

    or:
    Code:java
    1. Player player = event.getPlayer();
    2. if (player.hasPermission("Plugin.Node")){
    3. //Code where I use "player"
    4. } else {
    5. //Other code where I don't use Player, or just end of code
    6. }


    That makes any difference(faster/slower/more memory usage)?
    Or maybe that don't change anything? :p
     
  2. Offline

    Devil0s

    Modern computers are very powerful, so it's not important which solution you will choose.
    I would use the second one but that doesn't matter.
     
    bfgbfggf likes this.
  3. Offline

    Rocoty

    Yeah. Like Devil0s said
    Plus, using the second one would make your code more easily readable, so it's definitely the way to go.
     
    bfgbfggf likes this.
  4. Offline

    xTrollxDudex

    Rocoty
    bfgbfggf
    He's right. The second one is cleaner, and IS faster. By like, 2 milliseconds or something
     
    bfgbfggf likes this.
  5. Offline

    bfgbfggf

    Ok thanks.
     
Thread Status:
Not open for further replies.

Share This Page