mercredi 24 décembre 2014

What'd be better? To add one more local variable, or to call a method twice in general case?


I hvae the method which returns java.util.Date inside the hibernate-entity class: package ua.com.winforce.loto_partner.commons.db.entity;



@Entity
@Table(schema = "pr", name = "publice")
public class Pr {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private int id;

@Column(name = "reg_date")
private Date regDate;

//GET, SET
}


And in a method I need to create the local variable which will be hold getRegDate(); value, or to invoke that method twice. What would be more appropriate in that case? I mean, in the first case we're potentially closing the moment when GC will be triggered, but in the first we waste our time to the second method invokation.





Aucun commentaire:

Enregistrer un commentaire