title: Does fileprivate Extensions and Types in Swift improve compile time?
body: <p>If I keep my extension and private Types very confined inside one single Swift file because I will only ever need it inside that one file, will it improve compiler time and/or performance? Or is the Swift compiler so intelligent and doesn't matter at all?</p>
  
  <p>Example:
  One iOS Xcode project with over 600 Swift files (moderately huge project) with an already existing network class:</p>
  
  <p>NetworkController.swift</p>
  
  <pre><code>class NetworkController {
      let queue = OperationQueue()
  
      func add(_ op: Operation) {
          queue.addOperation(op)
      }
  }
  </code></pre>
  
  <p>Now I need to add a new class which only does a legacy operation. Which means that all the other components in the iOS app will never ever need it.</p>
  
  <p>LegacyController.swift (everything put into same file)</p>
  
  <pre><code>internal final class LegacyController {
      let network = NetworkController()
  
      func start() {
          network.requestSomeLegacyStuff {
              print("blub")
          }
          // do lots of other work here ...
      }
  }
  
  extension NetworkController {
      fileprivate func requestSomeLegacyStuff(success: () -&gt; Void) {
          let operation = RequestLegacyDataOperation()
  
          add(operation)
      }
  }
  
  fileprivate final class RequestLegacyDataOperation: Operation {
      // do lots of work here ...
  }
  </code></pre>
  
  <p><strong>VERSUS</strong> put them into their own files for better visibility and separation, but would then need to change to <code>internal</code> scope, which is not needed at all.</p>
  
  <p>LegacyController.swift</p>
  
  <pre><code>internal final class LegacyController {
      let network = NetworkController()
  
      func start() {
          network.requestSomeLegacyStuff {
              print("blub")
          }
          // do lots of other work here ...
      }
  }
  </code></pre>
  
  <p>NetworkController+LegacyStuff.swift</p>
  
  <pre><code>extension NetworkController {
      internal func requestSomeLegacyStuff(success: () -&gt; Void) {
          let operation = RequestLegacyDataOperation()
  
          add(operation)
      }
  }
  </code></pre>
  
  <p>RequestLegacyDataOperation.swift</p>
  
  <pre><code>internal final class RequestLegacyDataOperation: Operation {
      // do lots of work here ...
  }
  </code></pre>