@@ -17,12 +17,11 @@ public class SearchablePopup : PopupWindowContent
1717 /// <summary>
1818 /// Creates searchable popup using given properties.
1919 /// </summary>
20- public static void Show ( Rect activatorRect , int current , string [ ] options , Action < int > onSelect )
20+ public static void Show ( Rect activatorRect , int current , IReadOnlyList < string > options , Action < int > onSelect )
2121 {
2222 PopupWindow . Show ( activatorRect , new SearchablePopup ( activatorRect , current , options , onSelect ) ) ;
2323 }
2424
25-
2625 private readonly Action < int > onSelect ;
2726
2827 private readonly SearchArray searchArray ;
@@ -35,12 +34,11 @@ public static void Show(Rect activatorRect, int current, string[] options, Actio
3534 private Rect activatorRect ;
3635 private Rect toolbarRect ;
3736 private Rect contentRect ;
38-
3937
4038 /// <summary>
41- /// Constructor should be called only internally by the <see cref="Show(Rect, int, string[] , Action{int})"/> method.
39+ /// Constructor should be called only internally by the <see cref="Show(Rect, int, IReadOnlyList{String} , Action{int})"/> method.
4240 /// </summary>
43- private SearchablePopup ( Rect activatorRect , int startIndex , string [ ] options , Action < int > onSelect )
41+ private SearchablePopup ( Rect activatorRect , int startIndex , IReadOnlyList < string > options , Action < int > onSelect )
4442 {
4543 this . activatorRect = activatorRect ;
4644
@@ -57,7 +55,6 @@ private SearchablePopup(Rect activatorRect, int startIndex, string[] options, Ac
5755 } ;
5856 }
5957
60-
6158 private void SelectItem ( int index )
6259 {
6360 onSelect ( index ) ;
@@ -228,7 +225,6 @@ public override void OnGUI(Rect rect)
228225 GUI . enabled = false ;
229226 }
230227
231-
232228 private class SearchArray
233229 {
234230 public struct Item
@@ -243,19 +239,16 @@ public Item(int index, string label)
243239 }
244240 }
245241
246-
247242 private readonly List < Item > items ;
248- private readonly string [ ] options ;
243+ private readonly IReadOnlyList < string > options ;
249244
250-
251- public SearchArray ( string [ ] options )
245+ public SearchArray ( IReadOnlyList < string > options )
252246 {
253247 this . options = options ;
254248 items = new List < Item > ( ) ;
255249 Search ( string . Empty ) ;
256250 }
257251
258-
259252 public bool Search ( string filter )
260253 {
261254 if ( Filter == filter )
@@ -265,7 +258,8 @@ public bool Search(string filter)
265258
266259 items . Clear ( ) ;
267260 var simplifiedFilter = filter . ToLower ( ) ;
268- for ( var i = 0 ; i < options . Length ; i ++ )
261+ var optionsCount = options . Count ;
262+ for ( var i = 0 ; i < optionsCount ; i ++ )
269263 {
270264 var option = options [ i ] ;
271265 if ( string . IsNullOrEmpty ( filter ) || option . ToLower ( ) . Contains ( simplifiedFilter ) )
@@ -291,7 +285,6 @@ public Item GetItemAt(int index)
291285 return items [ index ] ;
292286 }
293287
294-
295288 public int ItemsCount => items . Count ;
296289
297290 public string Filter { get ; private set ; }
0 commit comments