Conversation
Co-authored-by: ormidales <46538211+ormidales@users.noreply.github.com>
Co-authored-by: ormidales <46538211+ormidales@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Optimize search for Accept-Language header
Optimiser la recherche de l’en-tête Feb 16, 2026
Accept-Language sur le chemin critique onBeforeSendHeaders
ormidales
approved these changes
Feb 16, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes the performance-critical onBeforeSendHeaders listener by eliminating unnecessary array allocation and improving header search efficiency. The extension spoofs the Accept-Language header on every main frame request, making this code path highly performance-sensitive.
Changes:
- Replaced
.find()method with indexedforloop for faster header lookup - Removed array spread operation (
[...details.requestHeaders]) to eliminate unnecessary copying - Maintained identical behavior: updates existing header or adds new one when missing
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Le traitement de
Accept-LanguagesuronBeforeSendHeadersfaisait une recherche viafind+ callback et copiait le tableau des headers à chaque requêtemain_frame. Sur un chemin exécuté très fréquemment, cela ajoute un coût évitable.Changement principal — recherche indexée
requestHeaders.find(...)par une boucleforindexée.acceptLanguageHeaderIndexpuis on met à jour en place si trouvé.Changement principal — mutation directe
const requestHeaders = [...details.requestHeaders].details.requestHeaderspour éviter allocation/copie superflues.Comportement conservé
Accept-Languageexiste : sa valeur est remplacée par la langue spoofée.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.