Skip to content

Conversation

@DarkDimius
Copy link
Contributor

To allow other phases to generate additional sections that refer to them.

@DarkDimius
Copy link
Contributor Author

@odersky please review

@DarkDimius DarkDimius mentioned this pull request Mar 18, 2015
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use a simple loop here:

for ((key, addr) <- mp.toList) mp(key) = adjusted(addr)

Shorter, clearer, faster.

Copy link
Member

Choose a reason for hiding this comment

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

Updating a mutable data structure during iteration doesn't work in general. I guess this is safe because you don't change the key set, but I would be cautious about using the same approach in general.

If you were to use an mutable.AnyRefMap rather than a mutable.Map (which is a good idea for performance reasons anyway), you can use mp.transformValues(adjusted).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's way I wrote the code this way: at the point when I am updating the datastructure, I'm already iterating over a different one.

Copy link
Contributor

Choose a reason for hiding this comment

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

@retronym: Good point. We could modify like this

for (key <- mp.keysIterator.toBuffer) mp(key) = adjusted(mp(key))

That looks like the most efficient safe solution. I believe efficiency is a concern here - these maps can become large.

Copy link
Member

Choose a reason for hiding this comment

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

Any reason to avoid AnyRefMap? IMO that should be the first choice when you need a map in the compiler. Its main claim to fame is that it can calls equals/hashCode rather than ==/``##` which is a non-negligible performance win.

@odersky
Copy link
Contributor

odersky commented Mar 19, 2015

Otherwise, LGTM

DarkDimius added a commit to dotty-staging/dotty that referenced this pull request Mar 25, 2015
DarkDimius added a commit to dotty-staging/dotty that referenced this pull request Apr 1, 2015
DarkDimius added a commit that referenced this pull request Apr 3, 2015
Populate addresses of symbols, types and trees after pickler
@DarkDimius DarkDimius merged commit 7c8fea7 into scala:master Apr 3, 2015
@allanrenucci allanrenucci deleted the pickler-modular branch December 14, 2017 19:24
tgodzik added a commit to tgodzik/scala3 that referenced this pull request May 27, 2025
Backport "Disallow empty parameter clauses in `extension` definition" to 3.3 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants