-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Cache Structure Dictionaries #2922
Conversation
init(_ value: [String: SourceKitRepresentable]) { | ||
self.value = value | ||
|
||
let substructure = value["key.substructure"] as? [SourceKitRepresentable] ?? [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This caching is mostly what this PR is about
Generated by 🚫 Danger |
f628909
to
c687c22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
Source/SwiftLintFramework/Rules/Lint/DiscardedNotificationCenterObserverRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintFramework/Rules/Lint/UnusedDeclarationRule.swift
Outdated
Show resolved
Hide resolved
Please add an entry in the "breaking changes" section of the changelog since this breaks backwards compatiblity with the API. |
9aa0aea
to
796cac6
Compare
796cac6
to
4fff698
Compare
Thanks for the updates and merging! Can you delete branches after you merge PRs if you don't need the branch any more? |
What
[String: SourceKitRepresentable]
->SourceKittenDictionary
File.structure.dictionary
Why
substructure
key too often, and since it is a computed property, too many objects will be created and removed upon accessing itNote
This is more of a suggestion. I totally understand that this is a big change.
Some minor stylistic improvements can be done( like namings and moving extensions in and out)
i.e. this one probably should be moved to
File.structurekinds
https://github.com/realm/SwiftLint/pull/2922/files#diff-74fa1a3ab98dac161c19949597728f07R9
This solution calculates all substructures of the original dictionary. Technically, this can lead to regression in time in some cases, if
substructure
is not used in rules.This is also can lead to some code duplication, in places, where it is still easier to work with
[Strings: SourekitRepresentable]
BTW in order to have backward compatible API, we should probably use duplicated methods which still works with
[String: SourceKitRepresentable]
and will wrap those under the hood.Please see #2924 and #2929 for the more improvements, based on this solution