@@ -88,13 +88,9 @@ private void SetSpacesTimestamp(IReadOnlyCollection<string> spaces, long ts)
8888 if ( spaces . Count == 0 )
8989 return ;
9090
91- var timestamps = new object [ spaces . Count ] ;
92- for ( var i = 0 ; i < timestamps . Length ; i ++ )
93- {
94- timestamps [ i ] = ts ;
95- }
96-
97- _updateTimestamps . PutMany ( spaces . ToArray ( ) , timestamps ) ;
91+ _updateTimestamps . PutMany (
92+ spaces . ToArray < object > ( ) ,
93+ ArrayHelper . Fill < object > ( ts , spaces . Count ) ) ;
9894 }
9995
10096 [ MethodImpl ( MethodImplOptions . Synchronized ) ]
@@ -103,49 +99,34 @@ public virtual bool IsUpToDate(ISet<string> spaces, long timestamp /* H2.1 has L
10399 if ( spaces . Count == 0 )
104100 return true ;
105101
106- var keys = new object [ spaces . Count ] ;
107- var index = 0 ;
108- foreach ( var space in spaces )
109- {
110- keys [ index ++ ] = space ;
111- }
112- var lastUpdates = _updateTimestamps . GetMany ( keys ) ;
102+ var lastUpdates = _updateTimestamps . GetMany ( spaces . ToArray < object > ( ) ) ;
113103 return lastUpdates . All ( lastUpdate => ! IsOutdated ( lastUpdate as long ? , timestamp ) ) ;
114104 }
115105
116106 [ MethodImpl ( MethodImplOptions . Synchronized ) ]
117107 public virtual bool [ ] AreUpToDate ( ISet < string > [ ] spaces , long [ ] timestamps )
118108 {
119- var results = new bool [ spaces . Length ] ;
109+ if ( spaces . Length == 0 )
110+ return Array . Empty < bool > ( ) ;
111+
120112 var allSpaces = new HashSet < string > ( ) ;
121113 foreach ( var sp in spaces )
122114 {
123115 allSpaces . UnionWith ( sp ) ;
124116 }
125117
126118 if ( allSpaces . Count == 0 )
127- {
128- for ( var i = 0 ; i < spaces . Length ; i ++ )
129- {
130- results [ i ] = true ;
131- }
119+ return ArrayHelper . Fill ( true , spaces . Length ) ;
132120
133- return results ;
134- }
121+ var keys = allSpaces . ToArray < object > ( ) ;
135122
136- var keys = new object [ allSpaces . Count ] ;
137123 var index = 0 ;
138- foreach ( var space in allSpaces )
139- {
140- keys [ index ++ ] = space ;
141- }
142-
143- index = 0 ;
144124 var lastUpdatesBySpace =
145125 _updateTimestamps
146126 . GetMany ( keys )
147127 . ToDictionary ( u => keys [ index ++ ] , u => u as long ? ) ;
148128
129+ var results = new bool [ spaces . Length ] ;
149130 for ( var i = 0 ; i < spaces . Length ; i ++ )
150131 {
151132 var timestamp = timestamps [ i ] ;
@@ -163,7 +144,7 @@ public virtual void Destroy()
163144 // not the responsibility of this class.
164145 }
165146
166- private bool IsOutdated ( long ? lastUpdate , long timestamp )
147+ private static bool IsOutdated ( long ? lastUpdate , long timestamp )
167148 {
168149 if ( ! lastUpdate . HasValue )
169150 {
0 commit comments