[PR #11467] [MERGED] Improve Base64::Decode performance #28598

Open
opened 2026-01-31 09:29:32 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/11467
Author: @lhecker
Created: 10/8/2021
Status: ✅ Merged
Merged: 10/26/2021
Merged by: @undefined

Base: main ← Head: dev/lhecker/base64-perf


📝 Commits (8)

  • 273f870 Improve Base64::Decode performance
  • 1b4181c Merge remote-tracking branch 'origin/main' into dev/lhecker/base64-perf
  • da3406d Improve documentation
  • e59eb93 Address spelling linter feedback
  • 60312dd Replace exceptions with HRESULTs
  • c27da5e Fix spelling
  • 9c8dc32 Fix _GetOscSetClipboard return value
  • 6be7ce6 Fix audit checks

📊 Changes

6 files changed (+215 additions, -236 deletions)

View changed files

📝 .github/actions/spelling/excludes.txt (+1 -0)
📝 src/terminal/parser/OutputStateMachineEngine.cpp (+13 -13)
📝 src/terminal/parser/base64.cpp (+127 -162)
📝 src/terminal/parser/base64.hpp (+1 -5)
📝 src/terminal/parser/ut_parser/Base64Test.cpp (+72 -55)
📝 src/terminal/parser/ut_parser/OutputEngineTest.cpp (+1 -1)

📄 Description

This commit renames Base64::s_Decode into Base64::Decode and improves its
average performance on short strings of less than 200 characters by 4.5x.
This is achieved by implementing a classic base64 decoder that reads 4
characters at a time and produces 3 output bytes. Furthermore a small
128 byte lookup table is used to quickly map characters to values.

PR Checklist

  • I work here
  • Tests added/passed

Validation Steps Performed

  • Run WSL in Windows Terminal
  • Run printf "\033]52;c;aHR0cHM6Ly9naXRodWIuY29tL21pY3Jvc29mdC90ZXJtaW5hbC9wdWxsLzExNDY3\a"
  • Clipboard contains https://github.com/microsoft/terminal/pull/11467 ✔️

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/11467 **Author:** [@lhecker](https://github.com/lhecker) **Created:** 10/8/2021 **Status:** ✅ Merged **Merged:** 10/26/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/lhecker/base64-perf` --- ### 📝 Commits (8) - [`273f870`](https://github.com/microsoft/terminal/commit/273f87013d3809a483a55c1c700bede56cca2cd4) Improve Base64::Decode performance - [`1b4181c`](https://github.com/microsoft/terminal/commit/1b4181c148ec3d9b6929c909d05aa4fbc305c4b7) Merge remote-tracking branch 'origin/main' into dev/lhecker/base64-perf - [`da3406d`](https://github.com/microsoft/terminal/commit/da3406d6cfa2ee52d85f8a1f2d9735255ebc7240) Improve documentation - [`e59eb93`](https://github.com/microsoft/terminal/commit/e59eb93b220a21b8a5bbe6eb97d8ac9274b53c00) Address spelling linter feedback - [`60312dd`](https://github.com/microsoft/terminal/commit/60312ddf56c7179d28b57c2bd1ee887f813c66d9) Replace exceptions with HRESULTs - [`c27da5e`](https://github.com/microsoft/terminal/commit/c27da5e6d9d2bcdfdad7b380fc2018aca89832db) Fix spelling - [`9c8dc32`](https://github.com/microsoft/terminal/commit/9c8dc32816322954602a0ec8f4e1b30daf6ec2b5) Fix _GetOscSetClipboard return value - [`6be7ce6`](https://github.com/microsoft/terminal/commit/6be7ce63b25dc95f78be68beaf91fd4072957675) Fix audit checks ### 📊 Changes **6 files changed** (+215 additions, -236 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/excludes.txt` (+1 -0) 📝 `src/terminal/parser/OutputStateMachineEngine.cpp` (+13 -13) 📝 `src/terminal/parser/base64.cpp` (+127 -162) 📝 `src/terminal/parser/base64.hpp` (+1 -5) 📝 `src/terminal/parser/ut_parser/Base64Test.cpp` (+72 -55) 📝 `src/terminal/parser/ut_parser/OutputEngineTest.cpp` (+1 -1) </details> ### 📄 Description This commit renames `Base64::s_Decode` into `Base64::Decode` and improves its average performance on short strings of less than 200 characters by 4.5x. This is achieved by implementing a classic base64 decoder that reads 4 characters at a time and produces 3 output bytes. Furthermore a small 128 byte lookup table is used to quickly map characters to values. ## PR Checklist * [x] I work here * [x] Tests added/passed ## Validation Steps Performed * Run WSL in Windows Terminal * Run `printf "\033]52;c;aHR0cHM6Ly9naXRodWIuY29tL21pY3Jvc29mdC90ZXJtaW5hbC9wdWxsLzExNDY3\a"` * Clipboard contains `https://github.com/microsoft/terminal/pull/11467` ✔️ --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:29:32 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28598