Skip to content

Minor improvements to the use of StringMap/StringSet #19292

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

Merged
merged 3 commits into from
Sep 14, 2018

Conversation

jrose-apple
Copy link
Contributor

  • Remove handrolled StringSetIterator in favor of keys()
  • Use llvm::StringSet instead of StringMap where appropriate
  • Replace StringMap with DenseMap when the keys don't need to be owned

An llvm::StringSet is "just" an llvm::StringMap where the values are
ignored, so the 'keys()' range already does what we need.

No functionality change.
@jrose-apple
Copy link
Contributor Author

Reviewers are mostly tagged to check that I didn't make a stupid mistake, particularly in components I don't spend much time in.

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test compiler performance

Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

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

Good catch!

@jrose-apple
Copy link
Contributor Author

@nkcsgexi: There are a bunch in SourceKit I was not confident about, so you may want to do a pass yourself, searching for "StringMap<" or "StringSet<".

@aschwaighofer
Copy link
Contributor

👍 for IRGen change

@swift-ci
Copy link
Contributor

Build comment file:

Compilation-performance test failed

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e600143e2913a14ec63294175680e23a3d1290bf

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e600143e2913a14ec63294175680e23a3d1290bf

@jrose-apple
Copy link
Contributor Author

@swift-ci please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test compiler performance

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@swift-ci

This comment has been minimized.

@swift-ci

This comment has been minimized.

@swift-ci

This comment has been minimized.

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci

This comment has been minimized.

@swift-ci

This comment has been minimized.

@jrose-apple
Copy link
Contributor Author

I can't win with this one. I guess I should have been more careful.

That is, where we aren't using the value for anything.

No functionality change.
StringMap always copies its strings into its own storage. A DenseMap
of StringRefs has the same caveats as any other use of StringRef, but
in the cases I've changed the string has very clear ownership that
outlives the map.

No functionality change, but should reduce memory usage and malloc
traffic a little.
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci

This comment has been minimized.

@swift-ci

This comment has been minimized.

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

return false;
seen = true;
return true;
return duplicates.insert(dependency.RawPath).second;
Copy link
Contributor

Choose a reason for hiding this comment

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

Clever!

@jrose-apple jrose-apple merged commit ac4a92a into swiftlang:master Sep 14, 2018
@jrose-apple jrose-apple deleted the get-out-the-map branch September 14, 2018 17:53
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.

5 participants