Skip to content

dont create a TreeMap if the underlying tree is unchanged#8738

Merged
retronym merged 1 commit intoscala:2.12.xfrom
mkeskells:2.12.x_TreeMap-1
Feb 26, 2020
Merged

dont create a TreeMap if the underlying tree is unchanged#8738
retronym merged 1 commit intoscala:2.12.xfrom
mkeskells:2.12.x_TreeMap-1

Conversation

@mkeskells
Copy link
Contributor

No description provided.

@scala-jenkins scala-jenkins added this to the 2.12.12 milestone Feb 21, 2020
@mkeskells mkeskells force-pushed the 2.12.x_TreeMap-1 branch 3 times, most recently from 0f179e0 to b1efbd8 Compare February 22, 2020 09:01
@diesalbla diesalbla added the library:collections PRs involving changes to the standard collection library label Feb 22, 2020
Copy link
Member

@retronym retronym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea for a backport. Safe, low hanging fruit. Happy for this to land in 2.12.11 if @lrytz agrees.

(2.12.12 may include the more ambitious backport of the efficient RedBlackTree #8749 )

@retronym retronym added the performance the need for speed. usually compiler performance, sometimes runtime performance. label Feb 26, 2020
@retronym retronym modified the milestones: 2.12.12, 2.12.11 Feb 26, 2020
/** A factory to create empty maps of the same type of keys.
*/
override def empty: TreeMap[A, B] = TreeMap.empty[A, B](ordering)
override def empty: TreeMap[A, B] = newMap(null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as in TreeSet: why create a new instance?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Echoing @mkeskells answer: TreeMap.empty isn't a singleton, it creates a new TreeMap instance with the implicitly supplied Ordering.

@retronym retronym merged commit b4c0225 into scala:2.12.x Feb 26, 2020
hamzaremmal pushed a commit to hamzaremmal/scala3 that referenced this pull request May 2, 2025
dont create a TreeMap if the underlying tree is unchanged
hamzaremmal pushed a commit to scala/scala3 that referenced this pull request May 7, 2025
dont create a TreeMap if the underlying tree is unchanged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

library:collections PRs involving changes to the standard collection library performance the need for speed. usually compiler performance, sometimes runtime performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants