@@ -842,10 +842,10 @@ internal unsafe String[] InternalGetSubKeyNames()
842
842
{
843
843
EnsureNotDisposed ( ) ;
844
844
int subkeys = InternalSubKeyCount ( ) ;
845
- String [ ] names = new String [ subkeys ] ; // Returns 0-length array if empty.
846
845
847
846
if ( subkeys > 0 )
848
847
{
848
+ String [ ] names = new String [ subkeys ] ;
849
849
char [ ] name = new char [ MaxKeyLength + 1 ] ;
850
850
851
851
int namelen ;
@@ -868,9 +868,11 @@ internal unsafe String[] InternalGetSubKeyNames()
868
868
names [ i ] = new String ( namePtr ) ;
869
869
}
870
870
}
871
+
872
+ return names ;
871
873
}
872
874
873
- return names ;
875
+ return Array . Empty < String > ( ) ;
874
876
}
875
877
876
878
/**
@@ -921,10 +923,10 @@ public unsafe String[] GetValueNames()
921
923
EnsureNotDisposed ( ) ;
922
924
923
925
int values = InternalValueCount ( ) ;
924
- String [ ] names = new String [ values ] ;
925
926
926
927
if ( values > 0 )
927
928
{
929
+ String [ ] names = new String [ values ] ;
928
930
char [ ] name = new char [ MaxValueLength + 1 ] ;
929
931
int namelen ;
930
932
@@ -953,9 +955,11 @@ public unsafe String[] GetValueNames()
953
955
names [ i ] = new String ( namePtr ) ;
954
956
}
955
957
}
958
+
959
+ return names ;
956
960
}
957
961
958
- return names ;
962
+ return Array . Empty < String > ( ) ;
959
963
}
960
964
961
965
/**
@@ -1201,10 +1205,7 @@ internal Object InternalGetValue(String name, Object defaultValue, bool doNotExp
1201
1205
try
1202
1206
{
1203
1207
char [ ] newBlob = new char [ checked ( blob . Length + 1 ) ] ;
1204
- for ( int i = 0 ; i < blob . Length ; i ++ )
1205
- {
1206
- newBlob [ i ] = blob [ i ] ;
1207
- }
1208
+ Array . Copy ( blob , 0 , newBlob , 0 , blob . Length ) ;
1208
1209
newBlob [ newBlob . Length - 1 ] = ( char ) 0 ;
1209
1210
blob = newBlob ;
1210
1211
}
@@ -1215,8 +1216,7 @@ internal Object InternalGetValue(String name, Object defaultValue, bool doNotExp
1215
1216
blob [ blob . Length - 1 ] = ( char ) 0 ;
1216
1217
}
1217
1218
1218
-
1219
- IList < String > strings = new List < String > ( ) ;
1219
+ var strings = new List < String > ( ) ;
1220
1220
int cur = 0 ;
1221
1221
int len = blob . Length ;
1222
1222
@@ -1250,8 +1250,7 @@ internal Object InternalGetValue(String name, Object defaultValue, bool doNotExp
1250
1250
cur = nextNull + 1 ;
1251
1251
}
1252
1252
1253
- data = new String [ strings . Count ] ;
1254
- strings . CopyTo ( ( String [ ] ) data , 0 ) ;
1253
+ data = strings . ToArray ( ) ;
1255
1254
}
1256
1255
break ;
1257
1256
case Interop . mincore . RegistryValues . REG_LINK :
0 commit comments