Skip to content

Commit

Permalink
UpdateCheck microoptimization
Browse files Browse the repository at this point in the history
No need to create a `Random` object and get a random ID from it if then it's overwritten with the stored value.
  • Loading branch information
Ivan-Perez authored and cmaglie committed Sep 16, 2019
1 parent 2e596c6 commit c432669
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/src/processing/app/UpdateCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ public UpdateCheck(Base base) {
public void run() {
//System.out.println("checking for updates...");

// generate a random id in case none exists yet
Random r = new Random();
long id = r.nextLong();

long id;
String idString = PreferencesData.get("update.id");
if (idString != null) {
id = Long.parseLong(idString);
} else {
// generate a random id in case none exists yet
Random r = new Random();
id = r.nextLong();
PreferencesData.set("update.id", String.valueOf(id));
}

Expand Down

0 comments on commit c432669

Please sign in to comment.