1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-19 08:52:15 +01:00

UpdateCheck microoptimization

No need to create a `Random` object and get a random ID from it if then it's overwritten with the stored value.
This commit is contained in:
Iván Pérez 2019-07-18 14:49:51 +02:00 committed by Cristian Maglie
parent 2e596c6eff
commit c43266964b

View File

@ -66,14 +66,14 @@ public class UpdateCheck implements Runnable {
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));
}