Skip to content
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

chore: Stripped dead code #4425

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

Conversation

Semty
Copy link
Contributor

@Semty Semty commented May 19, 2023


Description:

Stripped dead code throughout the project.
It's a good practice to perform from time to time, leaving only the code that is actually in use.

Note:

I'm not sure whether this project still accepts pull requests from not core team members.
@low-batt, it seems to me that you're the most active participant lately, could you, please, help me with that?

@low-batt
Copy link
Contributor

@Semty, you definitely do not need to be one of IINA's core developers to propose changes.

IINA is slow at reviewing and merging PRs as the senior developers are very busy. Usually it occurs in spurts when those developers have time to focus on IINA.

I am a newbie junior contributor. I don't merge, but I do review PRs. No promises, but I will try and find time to take a look at this one this weekend. This really needs a review by the senior developers as it covers areas of IINA I am unfamiliar with.

At the moment the senior developers are focused on getting a release out. The release branch as already been cut. The hold up is the need to patch some problems in the updated dependencies.

Commits going into develop now will be going into the following release. Which is why this is sort of a good time to clear out dead code. One concern is that there is resistance to refactoring/cleanup with so many PRs outstanding over the fear of introducing lots of merge conflicts.

While on the topic of contributing I should point out that although CONTRIBUTING indicates the latest version of Xcode must be used, at the moment we are building with Xcode 13 as well as Xcode 14 in order to support macOS 10.11 and 10.12, which Xcode 14 dropped.

@Semty
Copy link
Contributor Author

Semty commented May 20, 2023

@Semty, you definitely do not need to be one of IINA's core developers to propose changes.

IINA is slow at reviewing and merging PRs as the senior developers are very busy. Usually it occurs in spurts when those developers have time to focus on IINA.

I am a newbie junior contributor. I don't merge, but I do review PRs. No promises, but I will try and find time to take a look at this one this weekend. This really needs a review by the senior developers as it covers areas of IINA I am unfamiliar with.

At the moment the senior developers are focused on getting a release out. The release branch as already been cut. The hold up is the need to patch some problems in the updated dependencies.

Commits going into develop now will be going into the following release. Which is why this is sort of a good time to clear out dead code. One concern is that there is resistance to refactoring/cleanup with so many PRs outstanding over the fear of introducing lots of merge conflicts.

While on the topic of contributing I should point out that although CONTRIBUTING indicates the latest version of Xcode must be used, at the moment we are building with Xcode 13 as well as Xcode 14 in order to support macOS 10.11 and 10.12, which Xcode 14 dropped.

@low-batt hey! Got it, thank you so much for your thorough response 👌.
Let me know if you find anything that should not be removed, I'm open to fix it if needed

Copy link
Contributor

@low-batt low-batt left a comment

Choose a reason for hiding this comment

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

I pulled the PR locally, built IINA and confirmed IINA started and was able to play a video.

I'm unfamiliar with a lot of this code, so the real review must be done by the senior developers. I had planned on not requesting changes and leaving it to those developers to request changes as I am unsure as to whether they would agree with some of my comments. However…

I'm certain this PR in its current state will be rejected due to including changes to generated sources. This is an existing pitfall for new contributors. I have entered issue #4429 for the failure to properly identify generated sources. See that issue and my inline comment.

On my other comments, feel free to wait and see what the other developers think.

Thank you for proposing these changes to IINA!

iina/MPVCommand.swift Outdated Show resolved Hide resolved
@@ -1394,7 +1360,7 @@ class MPVController: NSObject {
}
}

fileprivate func mpvGetOpenGLFunc(_ ctx: UnsafeMutableRawPointer?, _ name: UnsafePointer<Int8>?) -> UnsafeMutableRawPointer? {
fileprivate func mpvGetOpenGLFunc(_: UnsafeMutableRawPointer?, _ name: UnsafePointer<Int8>?) -> UnsafeMutableRawPointer? {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will have to see what the senior developers think, but I'm strongly against removing the name of parameters, even if they are not used. After this change a developer reading this code can't tell what it is that is being passed and ignored.

Copy link
Member

Choose a reason for hiding this comment

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

+1 for not changing

iina/MPVOption.swift Outdated Show resolved Hide resolved
iina/MPVProperty.swift Outdated Show resolved Hide resolved
iina/ShooterSubtitle.swift Outdated Show resolved Hide resolved
_: CVDisplayLink, _: UnsafePointer<CVTimeStamp>,
_: UnsafePointer<CVTimeStamp>,
_: CVOptionFlags,
_: UnsafeMutablePointer<CVOptionFlags>,
_ context: UnsafeMutableRawPointer?) -> CVReturn {
Copy link
Contributor

Choose a reason for hiding this comment

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

Although unused with respects to the code, these parameter names effectively provide documentation for developers reading the code. See what the senior developers say, but I am against removing parameter names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I tend to disagree here. My two points:

  1. In my opinion, it actually better to omit some stuff that you don't need to perform your logic, you have less things to grasp and see only the important ones
  2. If you want to change/debug this piece of code, it's better if you're familiar with it a bit more than just knowing the parameter names. It can be done really easily by checking where this function is used (CVDisplayLinkSetOutputCallback) and locating the parameter (CVDisplayLinkOutputCallback). After that you'll see the complete documentation with everything you may need

But, of course, I understand that it can be a hot topic, so I'm fully okay to return parameter names in every function even if it's not used

Copy link
Contributor

Choose a reason for hiding this comment

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

On this one lets see what the senior developers think.

Copy link
Member

Choose a reason for hiding this comment

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

I'd like to keep it as it is.

iina/ViewLayer.swift Show resolved Hide resolved
@low-batt low-batt requested a review from uiryuu May 21, 2023 19:53
Copy link
Member

@saagarjha saagarjha left a comment

Choose a reason for hiding this comment

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

I appreciate konmari efforts. Lots of this needs to go. Deciding which parts, though, is complicated. In general, these things should probably not be removed:

  • Sets of related properties or methods that exist for completeness: e.g. if we have setString, setInt, setDouble, … it doesn't make sense to remove one of these because it's not used. People expect the full set of APIs to be available.
  • Things that were just added and intend to be used in the near future. Determining this will probably be hard. cc @lhc70000 @uiryuu since they should sign off on this.

Marking for changes because some of these definitely need to be rolled back–see the comments for the ones I spotted.

Comment on lines -17 to -18
/** Tags for "Open File/URL" menu item when "Always open file in new windows" is off. Vice versa. */
fileprivate let NormalMenuItemTag = 0
Copy link
Member

Choose a reason for hiding this comment

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

As far as I can tell this was never used, perhaps worth adjusting the code to reflect that?

iina/Aspect.swift Outdated Show resolved Hide resolved
@@ -55,7 +55,7 @@ class CollapseView: NSStackView {
updateContentView(animated: animated)
}

@objc private func triggerAction(_ sender: NSControl) {
@objc private func triggerAction() {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@Semty Semty May 23, 2023

Choose a reason for hiding this comment

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

@saagarjha hey! thank you for your review!

You can't remove this parameter, see https://developer.apple.com/library/archive/documentation/General/Conceptual/Devpedia-CocoaApp/TargetAction.html#//apple_ref/doc/uid/TP40009071-CH3-SW2

are you sure? it works on iOS to omit the sender

Copy link
Member

Choose a reason for hiding this comment

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

It's legal on iOS, but not on macOS. Things will mostly still work because the argument register will probably not get touched but it's good to do it correctly.

iina/Extensions.swift Show resolved Hide resolved
Comment on lines -73 to -79
/// A Boolean value that indicates whether this executable was an optimized (not debug) build.
#if DEBUG
let isDebug = true
#else
let isDebug = false
#endif

Copy link
Member

Choose a reason for hiding this comment

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

Pretty sure this was just added recently, @low-batt you should probably look at this and see if you needed it

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this was recently added as a part of issue #4383 / PR #4385. However my role in that issue was to just get it started and hand it off to @uiryuu. Will have to ask @uiryuu about this change.

Copy link
Member

Choose a reason for hiding this comment

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

Let keep this, although there isn't any code using this. We might want to use this in the future.

Comment on lines -337 to -340

if externalURL != nil {
self.isExternal = true
}
Copy link
Member

Choose a reason for hiding this comment

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

cc @lhc70000 did you intend to do something with this


func add(_ multiplier: CGFloat) -> NSSize {
return NSSize(width: width + multiplier, height: height + multiplier)

Copy link
Member

Choose a reason for hiding this comment

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

Remove spaces

Comment on lines -73 to -79
/// A Boolean value that indicates whether this executable was an optimized (not debug) build.
#if DEBUG
let isDebug = true
#else
let isDebug = false
#endif

Copy link
Member

Choose a reason for hiding this comment

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

Let keep this, although there isn't any code using this. We might want to use this in the future.

@@ -1394,7 +1360,7 @@ class MPVController: NSObject {
}
}

fileprivate func mpvGetOpenGLFunc(_ ctx: UnsafeMutableRawPointer?, _ name: UnsafePointer<Int8>?) -> UnsafeMutableRawPointer? {
fileprivate func mpvGetOpenGLFunc(_: UnsafeMutableRawPointer?, _ name: UnsafePointer<Int8>?) -> UnsafeMutableRawPointer? {
Copy link
Member

Choose a reason for hiding this comment

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

+1 for not changing

@@ -195,7 +195,7 @@ class ViewLayer: CAOpenGLLayer {
}

// MARK: Utils

Copy link
Member

Choose a reason for hiding this comment

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

Space

Copy link
Member

@uiryuu uiryuu left a comment

Choose a reason for hiding this comment

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

Just drop some comments here, will take a deeper look another day. Merge conflicts look scary but are surprisingly trivial.

@@ -11,7 +11,7 @@ import Cocoa
class Aspect: NSObject {

private var size: NSSize!

Copy link
Member

Choose a reason for hiding this comment

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

Space

@@ -20,7 +20,7 @@ class Aspect: NSObject {
size.width = newValue
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Space

_: CVDisplayLink, _: UnsafePointer<CVTimeStamp>,
_: UnsafePointer<CVTimeStamp>,
_: CVOptionFlags,
_: UnsafeMutablePointer<CVOptionFlags>,
_ context: UnsafeMutableRawPointer?) -> CVReturn {
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to keep it as it is.

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.

None yet

4 participants