-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] [bidi] Serialize base64 encoded string directly to bytes #16203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dotnet] [bidi] Serialize base64 encoded string directly to bytes #16203
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
User description
💥 What does this PR do?
There is no reason to keep base64 encoded string as
System.Stringtype, in any case it will be materialized tobyte[]. So let's do it.💡 Additional Considerations
It also reduces memory allocation, capturing screenshot: before 824.87 KB, after 655.86 KB
🔄 Types of changes
PR Type
Enhancement
Description
Replace base64 string handling with direct byte arrays
Reduce memory allocation by ~20% for screenshot operations
Update BiDi commands to use
ReadOnlyMemory<byte>typeEliminate unnecessary base64 string conversions
Diagram Walkthrough
File Walkthrough
CaptureScreenshotCommand.cs
Update screenshot result to use byte memorydotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshotCommand.cs
CaptureScreenshotResult.DatafromstringtoReadOnlyMemoryToByteArray()to use direct array conversionSystemnamespace importPrintCommand.cs
Update print result to use byte memorydotnet/src/webdriver/BiDi/BrowsingContext/PrintCommand.cs
PrintResult.DatafromstringtoReadOnlyMemoryToByteArray()method implementationBytesValue.cs
Update bytes value to use memory typedotnet/src/webdriver/BiDi/Network/BytesValue.cs
Base64BytesValue.ValuefromstringtoReadOnlyMemoryInstallCommand.cs
Update extension data to use byte memorydotnet/src/webdriver/BiDi/WebExtension/InstallCommand.cs
ExtensionBase64Encoded.ValuefromstringtoReadOnlyMemorySystemnamespace importWebExtensionTest.cs
Update test for direct byte usagedotnet/test/common/BiDi/WebExtension/WebExtensionTest.cs