Commit 156d42d
committed
Cache custom JSON enum names in JsonParser using Lazy.
Custom JSON enum names are defined in descriptor options and looked up
when parsing JSON strings. Instead of performing a linear scan over
Values on each lookup, this change adds a ConcurrentDictionary with
Lazy<Dictionary> to JsonParser to lazily construct and cache the JSON
name to EnumValueDescriptor lookup table per EnumDescriptor on first
access.
Lazy provides thread-safe, lock-free reads on all subsequent accesses.
PiperOrigin-RevId: 9635834751 parent f11aac4 commit 156d42d
1 file changed
Lines changed: 35 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
756 | 758 | | |
757 | 759 | | |
758 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
759 | 786 | | |
760 | 787 | | |
761 | 788 | | |
762 | 789 | | |
763 | 790 | | |
764 | 791 | | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
776 | 800 | | |
777 | 801 | | |
778 | 802 | | |
| |||
0 commit comments