java - Eficiency of "pre-casting" vs casting each time -
Sometimes you need a branch based on In this case, make the code more efficient by creating the desired local variables, or is it only a visual improvement? Casting is a small cost because it is to check that typing is appropriate ( Otherwise it does not really make any changes) However, in this case you can assume that JIT will optimize this check so that once done after writing this code it will be done. If the code is not run to run adequately (which is quite likely) then the code will be slightly slower, but it does not matter because it is not enough, i.e. the performance difference between jit and gitid away is high. instance , and then something on the concrete type Do actions.
if (obj instanceof IonObject) {Ion.assertRegistered (IonObject) obj); Write Mark (obj ((ion object)) .getIonMark ()); ((Ion object) OBG). Saving (this); Return; }
if (Obj instanceof IonObject) {// cache valuable value IonObject iobj = (IonObject) obj; Ion.assertRegistered (iobj); writeMark (iobj.getIonMark ()); iobj.save (this); Return; }
Comments
Post a Comment