Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: UseXmlWriter to serialize TwiML instead of usingXDocument#669

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Swimburger wants to merge4 commits intotwilio:main
base:main
Choose a base branch
Loading
fromSwimburger:use-xml-writer

Conversation

Swimburger
Copy link
Contributor

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

Currently the TwiML tree is constructed as a tree of objects which are then converted into a tree of objects from theSystem.Xml.Linq, to then be serialized to a string usingXDocument.Save.
This creates three copies of the same data in memory, one as TwiML objects, one asSystem.Xml.Linq objects, and one as a string.

To reduce the amount of memory used and increase performance, this PR uses theXmlWriter APIs instead ofSystem.Xml.Linq APIs.

The TwiML tree is constructed just the same, but that tree is serialized without creating another copy of the tree, and can be written directly toStreams,TextWriters, andXmlWriters.
If theStream is a file stream, a network stream, etc., the entire XML string wouldn't be loaded into memory as a result.
If you do use aTextWriter or theToString method, the string would be loaded in memory but this PR won't create another copy of the tree asSystem.Xml.Linq objects.

The resulting XML uses self-closing tags at the moment, which would reduce the size of the string and make HTTP responses containing TwiML smaller, but this can be reverted if necessary for backwards compatibility reasons.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read theContribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

@Swimburger
Copy link
ContributorAuthor

C'mon Twilio folks, this code contribution has been ready to merge on the internal repo and public repo for a long time. The longer you let these things rot, the more conflicts will arise.

By not merging this, you're choosing to keep a slower and less memory-efficient version around for no reason. 🔥 🌳

@Swimburger
Copy link
ContributorAuthor

✌️

@tiwarishubham635
Copy link
Contributor

Hello@Swimburger! Sincere apologies from my side for missing this one. I would request you to re-open this and I'd be happy to help your contributions get merged. I will be looking at this on priority. Thanks!

Since these are auto-generated files, we would need to do similar change in the internal tool as well. I'll check with that as well

@Swimburger
Copy link
ContributorAuthor

I don't recall whether I created a PR for this internally when I was at Twilio.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@Swimburger@tiwarishubham635

[8]ページ先頭

©2009-2025 Movatter.jp