Skip to content

Commit 6462c92

Browse files
authored
Improve performance when setting RC defaults (#469)
* Improve performance when setting RC defaults * Update remote_config.i
1 parent 778a484 commit 6462c92

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

docs/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ Release Notes
159159
- Changes
160160
- Auth (Android/iOS): Deprecate `PhoneAuthProvider.MaxTimeoutMs`. The actual
161161
range is determined by the underlying SDK, ex. [PhoneAuthOptions.Builder in Android SDK](https://firebase.google.com/docs/reference/android/com/google/firebase/auth/PhoneAuthOptions.Builder).
162+
- Remote Config: Improve performance when setting default parameters
163+
with long strings.
162164

163165
### 9.6.0
164166
- Changes

remote_config/src/swig/remote_config.i

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,26 +198,27 @@ struct ConfigValueInternal {
198198

199199
foreach (System.Collections.Generic.KeyValuePair<string, object>
200200
pair in oldMap) {
201-
string toStore;
202-
if (pair.Value is System.Collections.Generic.IEnumerable<byte>) {
201+
if (pair.Value is string) {
202+
newMap[pair.Key] = pair.Value as string;
203+
} else if (pair.Value is System.Collections.Generic.IEnumerable<byte>) {
203204
// For lists of bytes, match the UTF8 conversion used by the base
204205
// implementation.
205206
var list =
206207
new System.Collections.Generic.List<byte>(
207208
pair.Value as System.Collections.Generic.IEnumerable<byte>);
208-
toStore = System.Text.Encoding.UTF8.GetString(list.ToArray());
209+
newMap[pair.Key] = System.Text.Encoding.UTF8.GetString(list.ToArray());
209210
} else if (pair.Value is System.Collections.IEnumerable) {
210211
// For other collections, just try to convert the inner values.
211212
var list = pair.Value as System.Collections.IEnumerable;
212-
toStore = "";
213+
var stringBuilder = new System.Text.StringBuilder();
213214
foreach (object obj in list) {
214-
toStore += obj.ToString();
215+
stringBuilder.Append(obj);
215216
}
217+
newMap[pair.Key] = stringBuilder.ToString();
216218
} else {
217219
// For everything else, go straight to a string.
218-
toStore = pair.Value.ToString();
220+
newMap[pair.Key] = pair.Value.ToString();
219221
}
220-
newMap[pair.Key] = toStore;
221222
}
222223

223224
return newMap;

0 commit comments

Comments
 (0)