Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Commit

Permalink
Dropped boilerplate code for Hashable and Equatable
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanTysiachnik committed Jan 29, 2019
1 parent 9aad518 commit 62942c2
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 62 deletions.
2 changes: 1 addition & 1 deletion PlayerCore
4 changes: 0 additions & 4 deletions VerizonVideoPartnerSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@
DE4C51C61C8094FE00BFFB0B /* MetricsSender.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4C51531C80731B00BFFB0B /* MetricsSender.swift */; };
DE4C51D71C80957B00BFFB0B /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4C51D51C80957B00BFFB0B /* Player.swift */; };
DE4C51E11C80D43200BFFB0B /* TrackingPixelsConnector.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4C51E01C80D43200BFFB0B /* TrackingPixelsConnector.swift */; };
DE5F27E11F44501E00011E2C /* PlayerActionsJSONTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE5F27E01F44501E00011E2C /* PlayerActionsJSONTests.swift */; };
DE684CD71E0C2F36007CE35C /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE684CD61E0C2F36007CE35C /* Action.swift */; };
DE684CD81E0C2F36007CE35C /* Action.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE684CD61E0C2F36007CE35C /* Action.swift */; };
DE684CDC1E0EBFC3007CE35C /* SystemPlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5067F5FE1D49120E00FEC27C /* SystemPlayerViewController.swift */; };
Expand Down Expand Up @@ -591,7 +590,6 @@
DE4C51D51C80957B00BFFB0B /* Player.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Player.swift; sourceTree = "<group>"; };
DE4C51D61C80957B00BFFB0B /* ObserverTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ObserverTests.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
DE4C51E01C80D43200BFFB0B /* TrackingPixelsConnector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackingPixelsConnector.swift; sourceTree = "<group>"; };
DE5F27E01F44501E00011E2C /* PlayerActionsJSONTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerActionsJSONTests.swift; sourceTree = "<group>"; };
DE611A791E9D40F200D253B2 /* PlayerControls.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PlayerControls.xcodeproj; path = PlayerControls/PlayerControls/PlayerControls.xcodeproj; sourceTree = "<group>"; };
DE684CD61E0C2F36007CE35C /* Action.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Action.swift; sourceTree = "<group>"; };
DE79CE201E979F9700C3A660 /* AdURLProviderProcess.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdURLProviderProcess.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1009,7 +1007,6 @@
children = (
50E5ADE71EE0428A004104D6 /* PlayerTracer.playground */,
50E5ADE81EE08A76004104D6 /* PlayerTracer.swift */,
DE5F27E01F44501E00011E2C /* PlayerActionsJSONTests.swift */,
);
name = tracer;
sourceTree = "<group>";
Expand Down Expand Up @@ -1998,7 +1995,6 @@
E22B6AD921EF852800D480A0 /* VRMProcessingControllerTest.swift in Sources */,
FE940A001F3DD56600A867CD /* IntentDetectorTests.swift in Sources */,
50A12D031CE639160088A74E /* NetworkTests.swift in Sources */,
DE5F27E11F44501E00011E2C /* PlayerActionsJSONTests.swift in Sources */,
50D747891CE624E200CB91D4 /* VRMRequestTests.swift in Sources */,
061CFFFC211C7263002B5BE9 /* MuteDetectorTests.swift in Sources */,
508A597E2010F97B00641398 /* VRMDetectorTests.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion VideoRenderer
16 changes: 0 additions & 16 deletions sources/advertisements/AdManagerPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,3 @@ final class AdManager<Result> {
}
}
}

extension VRMProvider.Item: Hashable {
var hashValue: Int {
switch self {
case let .vast(string, _): return string.hashValue
case let .url(url, _): return url.hashValue
}
}
}

func == (left: VRMProvider.Item, right: VRMProvider.Item) -> Bool {
switch (left, right) {
case (let .vast(lh, _), let .vast(rh, _)): return lh == rh
case (let .url(lh, _), let .url(rh, _)): return lh == rh
default: return false }
}
15 changes: 1 addition & 14 deletions sources/advertisements/MidrollDetector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func playAction(input: MidrollDetector.Input,
class MidrollDetector {
typealias Midroll = PlayerCore.Ad.Midroll

enum Action {
enum Action: Hashable {
case prefetch(Midroll)
case play(PlayerCore.Ad.VASTModel?, Midroll)
}
Expand Down Expand Up @@ -138,16 +138,3 @@ extension MidrollDetector.Input {
hasActiveAds = item.hasActiveAds
}
}


extension MidrollDetector.Action: Equatable {
static func ==(lhs: MidrollDetector.Action, rhs: MidrollDetector.Action) -> Bool {
switch (lhs, rhs) {
case (.prefetch(let lhsMidroll), .prefetch(let rhsMidroll)):
return lhsMidroll == rhsMidroll
case (.play(let lhsPrefetchedModel, let lhsPrefetchedMidroll), .play(let rhsPrefetchedModel, let rhsPrefetchedMidroll)):
return lhsPrefetchedModel == rhsPrefetchedModel && lhsPrefetchedMidroll == rhsPrefetchedMidroll
default: return false
}
}
}
4 changes: 2 additions & 2 deletions sources/advertisements/VRMProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ struct VRMProvider {
throw Error.CannotExtractAdEngineFromJSON(json)
}

enum Item {
struct MetaInfo {
enum Item: Hashable {
struct MetaInfo: Hashable {
let engineType: String?
let ruleId: String?
let ruleCompanyId: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension Detectors {
var isProcessed = false
var timePlayed: Double = 0

struct Result {
struct Result: Hashable {
let duration: Double
let time: Double
let videoIndex: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,3 @@ class AdViewTimeDetectorTests: XCTestCase {
}

}

extension Detectors.AdViewTime.Result: Equatable {
public static func ==(lhs: Detectors.AdViewTime.Result, rhs: Detectors.AdViewTime.Result) -> Bool {
return lhs.duration == rhs.duration
&& lhs.time == rhs.time
&& lhs.videoIndex == rhs.videoIndex
&& lhs.vvuid == rhs.vvuid
}
}
13 changes: 0 additions & 13 deletions sources/player/PlayerActionsJSONTests.swift

This file was deleted.

2 changes: 1 addition & 1 deletion sources/player/VideoSelector.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright © 2018 Oath Inc
// Licensed under the terms of the MIT License. See LICENSE.md file in project root for terms.

struct VideoSelector {
struct VideoSelector: Equatable {
let index: Int

init(index: Int, currentIndex: Int?, playlistCount: Int) throws {
Expand Down

0 comments on commit 62942c2

Please sign in to comment.