File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -72,8 +72,7 @@ public int idCount
7272 [ DoNotSerialize ]
7373 public List < ValueInput > LampIdValues { get ; private set ; }
7474
75- private List < LampIdValue > _lampIdValueList ;
76- private int _hash ;
75+ private Dictionary < int , LampIdValue > _lampIdValueCache = new Dictionary < int , LampIdValue > ( ) ;
7776
7877 protected override void Definition ( )
7978 {
@@ -91,6 +90,8 @@ protected override void Definition()
9190 Requirement ( valueInput , InputTrigger ) ;
9291 }
9392
93+ _lampIdValueCache . Clear ( ) ;
94+
9495 Succession ( InputTrigger , OutputTrigger ) ;
9596 }
9697
@@ -104,7 +105,13 @@ private ControlOutput Process(Flow flow)
104105 var value = flow . GetValue < int > ( Value ) ;
105106
106107 foreach ( var lampIdValue in LampIdValues ) {
107- var obj = LampIdValue . FromJson ( flow . GetValue < string > ( lampIdValue ) ) ;
108+ var json = flow . GetValue < string > ( lampIdValue ) ;
109+
110+ if ( ! _lampIdValueCache . ContainsKey ( json . GetHashCode ( ) ) ) {
111+ _lampIdValueCache [ json . GetHashCode ( ) ] = LampIdValue . FromJson ( json ) ;
112+ }
113+
114+ var obj = _lampIdValueCache [ json . GetHashCode ( ) ] ;
108115 Gle . SetLamp ( obj . id , obj . value == value ? 255f : 0f ) ;
109116 }
110117
You can’t perform that action at this time.
0 commit comments