Skip to content

Performed small cleanups and refactors to silence warnings#214

Merged
cmyr merged 2 commits into
xi-editor:masterfrom
nangtrongvuon:cleanup-refactor
Jul 6, 2018
Merged

Performed small cleanups and refactors to silence warnings#214
cmyr merged 2 commits into
xi-editor:masterfrom
nangtrongvuon:cleanup-refactor

Conversation

@nangtrongvuon
Copy link
Copy Markdown
Member

The small cleanups performed in this patch were:

  • Updating the project's build settings to XCode's recommended settings

Mostly to silence build warnings.

  • Change objc inference to Default, which is recommended in Swift 4

More info on this can be seen at the proposal for this change. For xi-mac, this would remove extraneous objc entry points, which has been seen to increase binary size and adversely impact load time. Since we already explicitly define objc entry points when interacting with UI elements, this change would not affect us too much.

  • Removed check for C.IndexDistance == Int, which is deprecated in Swift
    4 as IndexDistance are all now Ints

Since we are now on Swift 4, checking for IndexDistance type for Int is no longer required.

  • Change addConstraint calls to changing isActive instead, recommended
    by Apple

From the addConstraint docs:

When developing for iOS 8.0 or later, set the constraint’s isActive property to true instead of calling the addConstraint(_:) method directly. The isActive property automatically adds and removes the constraint from the correct view.

Barring the iOS part, using isActive instead of addConstraint would avoid cases where the constraints are added to wrong views, which can happen often when working with subviews.

The small cleanups performed in this patch was:
- Update the project's build settings to XCode's recommended settings
- Change objc inference to Default, which is recommended in Swift 4
- Removed check for C.IndexDistance == Int, which is deprecated in Swift
4 as IndexDistance are all now Ints
- Change addConstraint calls to changing isActive instead, recommended
by Apple
Copy link
Copy Markdown
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

Cool, this all looks good. Thanks!

Comment thread XiEditor/EditViewController.swift Outdated
// Determines the gesture type based on flags and click count.
private func clickGestureType(event: NSEvent) -> String {
let flags = event.modifierFlags.rawValue >> 16
_ = event.modifierFlags.rawValue >> 16
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is a relic of how we used to send modifiers; we can just remove it now.

Copy link
Copy Markdown
Member

@raphlinus raphlinus left a comment

Choose a reason for hiding this comment

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

Always nice to have silent warnings, thanks.

@cmyr cmyr merged commit 73dce0d into xi-editor:master Jul 6, 2018
@nangtrongvuon nangtrongvuon deleted the cleanup-refactor branch July 7, 2018 03:55
@nangtrongvuon
Copy link
Copy Markdown
Member Author

@raphlinus You meant not having them? :P

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.

3 participants