Created
June 14, 2016 12:54
-
-
Save samuelbeek/3fd61dae6d9e0c3a4ed81c2a17a4ca9c to your computer and use it in GitHub Desktop.
Making Cartography compile faster.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CartographyExtensions.swift | |
// portkey | |
// | |
// Created by Samuel Beek on 14/06/16. | |
// | |
// Note: still WIP. I only dealt with the equality operator (==), haven't worked on <= and ~ yet. | |
// But adding this won't be bad for you project, it saves me 70% compile time per block on avarage. | |
import Foundation | |
public func makeEqual<P: RelativeEquality>(lhs: P, _ rhs: Expression<P>) -> NSLayoutConstraint { | |
return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients[0], to: rhs.value) | |
} | |
public func makeEqual<P: RelativeEquality>(lhs: P, _ rhs: P) -> NSLayoutConstraint { | |
return lhs.context.addConstraint(lhs, to: rhs) | |
} | |
public func makeEqual(lhs: NumericalEquality, _ rhs: CGFloat) -> NSLayoutConstraint { | |
return lhs.context.addConstraint(lhs, coefficients: Coefficients(1, rhs)) | |
} | |
public func makeEqual<P: RelativeCompoundEquality>(lhs: P, _ rhs: P) -> [NSLayoutConstraint] { | |
return lhs.context.addConstraint(lhs, to: rhs) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist inspired a pull-request I created on Cartography, see here: robb/Cartography#293. Thanks!