Skip to content

Commit

Permalink
Add SourceKit response cache for reducing calls to SourceKit
Browse files Browse the repository at this point in the history
This depends on jpsim/SourceKitten#135
By applying this, the duration of linting Carthage is reduced from:
```
swiftlint lint  27.85s user 1.98s system 77% cpu 38.538 total
```
to:
```
swiftlint lint  21.15s user 1.26s system 80% cpu 27.743 total
```
  • Loading branch information
norio-nomura committed Jan 9, 2016
1 parent d9a885e commit 755619d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Add AutoCorrect for LegacyConstructorRule.
[Raphael Randschau](https://github.com/nicolai86)

* Improve performance by reducing calls to SourceKit.
[Norio Nomura](https://github.com/norio-nomura)

##### Bug Fixes

* AutoCorrect for TrailingNewlineRule only removes at most one line.
Expand Down
5 changes: 3 additions & 2 deletions Source/SwiftLintFramework/Extensions/File+Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

import SourceKittenFramework

private var structureCache = Cache({file in Structure(file: file)})
private var syntaxMapCache = Cache({file in SyntaxMap(file: file)})
private var responseCache = Cache({file in Request.EditorOpen(file).send()})
private var structureCache = Cache({file in Structure(sourceKitResponse: responseCache.get(file))})
private var syntaxMapCache = Cache({file in SyntaxMap(sourceKitResponse: responseCache.get(file))})

private struct Cache<T> {

Expand Down

0 comments on commit 755619d

Please sign in to comment.