Sho SHIMIZU
Committed by Gerrit Code Review

Avoid creating an instance when calling resource()

Change-Id: I0d831cc51199bce0e0dc2b7bb1b5bc2df9fbf90b
...@@ -23,6 +23,7 @@ import com.google.common.annotations.Beta; ...@@ -23,6 +23,7 @@ import com.google.common.annotations.Beta;
23 @Beta 23 @Beta
24 public final class DiscreteFactory { 24 public final class DiscreteFactory {
25 private final DiscreteResourceId id; 25 private final DiscreteResourceId id;
26 + private final DiscreteResource resource;
26 27
27 /** 28 /**
28 * Create an instance with the specified resource ID. 29 * Create an instance with the specified resource ID.
...@@ -32,6 +33,7 @@ public final class DiscreteFactory { ...@@ -32,6 +33,7 @@ public final class DiscreteFactory {
32 */ 33 */
33 DiscreteFactory(DiscreteResourceId id) { 34 DiscreteFactory(DiscreteResourceId id) {
34 this.id = id; 35 this.id = id;
36 + this.resource = new DiscreteResource(id);
35 } 37 }
36 38
37 /** 39 /**
...@@ -49,6 +51,6 @@ public final class DiscreteFactory { ...@@ -49,6 +51,6 @@ public final class DiscreteFactory {
49 * @return discrete-type resource 51 * @return discrete-type resource
50 */ 52 */
51 public DiscreteResource resource() { 53 public DiscreteResource resource() {
52 - return new DiscreteResource(id); 54 + return resource;
53 } 55 }
54 } 56 }
......