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

UsetoVector for XML literal sequences#11065

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
lrytz wants to merge1 commit intoscala:2.13.x
base:2.13.x
Choose a base branch
Loading
fromlrytz:xmlVector

Conversation

lrytz
Copy link
Member

In<a><b/><c/><a>, aNodeBuffer (which extendsArrayBuffer) is used to accumulate the children. The buffer is passed tonew Elem($buf: _*), which only works thanks to the implicitcollection.Seq[Node] => NodeSeq declared in scala-xml.

With-Vprint:typer:

scala> <a><b/></a>[[syntax trees at end of                     typer]]// <console>private[this]valres0: scala.xml.Elem=new scala.xml.Elem(null,"a", scala.xml.Null, scala.xml.TopScope,false, (xml.this.NodeSeq.seqToNodeSeq({val$buf: scala.xml.NodeBuffer=new scala.xml.NodeBuffer();        $buf.&+(new scala.xml.Elem(null,"b", scala.xml.Null, scala.xml.TopScope,true));        $buf      }):_*));

The implicit was not inserted in 2.12 because the varargs parameter of Elem accepted acollection.Seq.

@scala-jenkinsscala-jenkins added this to the2.13.17 milestoneMay 20, 2025
@lrytz
Copy link
MemberAuthor

I went forVector because it's more compact thanList, and it's more efficient thanList orArraySeq for concatenation / prepending / appending.NodeSeq.newBuilder uses aListBuffer though..

SethTisue reacted with thumbs up emoji

@lrytz
Copy link
MemberAuthor

lrytz commentedMay 20, 2025
edited
Loading

... this affects IntelliJ not anymore, updated the PR so that plain XML sequences keep typeNodeBuffer.

image

In `<a><b/><c/><a>`, a `NodeBuffer` (which extends `ArrayBuffer`) isused to accumulate the children. The buffer is passed to`new Elem($buf: _*)`, which only works thanks to the implicit`collection.Seq[Node] => NodeSeq` declared in scala-xml.With `-Vprint:typer`:```scalascala> <a><b/></a>[[syntax trees at end of                     typer]] // <console>      private[this] val res0: scala.xml.Elem = new scala.xml.Elem(null, "a", scala.xml.Null, scala.xml.TopScope, false, (xml.this.NodeSeq.seqToNodeSeq({        val $buf: scala.xml.NodeBuffer = new scala.xml.NodeBuffer();        $buf.&+(new scala.xml.Elem(null, "b", scala.xml.Null, scala.xml.TopScope, true));        $buf      }): _*));```The implicit was not inserted in 2.12 because the varargs parameter ofElem accepted a `collection.Seq`.
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
2.13.17
Development

Successfully merging this pull request may close these issues.

2 participants
@lrytz@scala-jenkins

[8]ページ先頭

©2009-2025 Movatter.jp