Commit 6dd07b1
authored
### Rationale for this change
The current implementation of `base64_decode` validates characters using `std::string::find` for each byte, which introduces unnecessary overhead due to repeated linear searches.
This change replaces those lookups with a precomputed 256-entry lookup table, enabling constant-time validation and value lookup per character.
### What changes are included in this PR?
- Introduced a static lookup table (`kBase64Lookup`) to map base64 characters to their corresponding values
- Replaced `std::string::find` with constant-time table lookup for character validation
### Are these changes tested?
Yes. Existing base64 decoding behavior remains unchanged and continues to pass all current tests. This change is a performance optimization and does not alter functional output.
### Are there any user-facing changes?
No.
This change is internal and does not affect public APIs.
* GitHub Issue: #49720
Authored-by: Aaditya Srinivasan <aadityasri03@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 8595105 commit 6dd07b1
1 file changed
+18
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
43 | 56 | | |
44 | 57 | | |
45 | 58 | | |
| |||
119 | 132 | | |
120 | 133 | | |
121 | 134 | | |
122 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
123 | 138 | | |
124 | 139 | | |
125 | 140 | | |
126 | | - | |
| 141 | + | |
127 | 142 | | |
128 | 143 | | |
129 | 144 | | |
130 | 145 | | |
131 | 146 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | 147 | | |
139 | 148 | | |
140 | 149 | | |
| |||
0 commit comments