google / google/json_serializable.dart

enumDecode performance

Open
#1,143 3 comments 6 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
1.6k
Forks
461
Avg merge
45m
Merged PRs (30d)
1

Description

I'm noticing json_serializable's `enumDecode` function iterates over the values of a map containing the enum values. Wouldn't it be better to generate a reversed map and use it for this purpose ? It could possibility impact performance over large quantities of data.
Has anyone investigated this performance impact before ?

Relevant code at `enum_helpers.dart` line 76 :
```dart
for (var entry in enumValues.entries) {
if (entry.value == source) {
return entry.key;
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.