Skip to content

Commit

Permalink
Remove composeMap test
Browse files Browse the repository at this point in the history
  • Loading branch information
M0rtyMerr authored and freak4pc committed Feb 8, 2020
1 parent 3aa17b2 commit ba102f5
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 94 deletions.
4 changes: 0 additions & 4 deletions RxBlocking/Resources.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import RxSwift
return RxSwift.Resources.numberOfSerialDispatchQueueObservables
}

static var numberOfMapOperators: Int32 {
return RxSwift.Resources.numberOfMapOperators
}

static var total: Int32 {
return RxSwift.Resources.total
}
Expand Down
19 changes: 0 additions & 19 deletions RxSwift/Observables/Map.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ final private class MapSink<SourceType, Observer: ObserverType>: Sink<Observer>,
}
}

#if TRACE_RESOURCES
private let _numberOfMapOperators = AtomicInt(0)
extension Resources {
public static var numberOfMapOperators: Int32 {
return load(_numberOfMapOperators)
}
}
#endif

final private class Map<SourceType, ResultType>: Producer<ResultType> {
typealias Transform = (SourceType) throws -> ResultType

Expand All @@ -76,21 +67,11 @@ final private class Map<SourceType, ResultType>: Producer<ResultType> {
init(source: Observable<SourceType>, transform: @escaping Transform) {
self._source = source
self._transform = transform

#if TRACE_RESOURCES
_ = increment(_numberOfMapOperators)
#endif
}

override func run<Observer: ObserverType>(_ observer: Observer, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where Observer.Element == ResultType {
let sink = MapSink(transform: self._transform, observer: observer, cancel: cancel)
let subscription = self._source.subscribe(sink)
return (sink: sink, subscription: subscription)
}

#if TRACE_RESOURCES
deinit {
_ = decrement(_numberOfMapOperators)
}
#endif
}
4 changes: 0 additions & 4 deletions Tests/Resources.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import RxSwift
return RxSwift.Resources.numberOfSerialDispatchQueueObservables
}

static var numberOfMapOperators: Int32 {
return RxSwift.Resources.numberOfMapOperators
}

static var total: Int32 {
return RxSwift.Resources.total
}
Expand Down
67 changes: 0 additions & 67 deletions Tests/RxSwiftTests/Observable+MapTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -384,71 +384,4 @@ extension ObservableMapTest {
XCTAssertEqual(res.events, correctMessages)
XCTAssertEqual(xs.subscriptions, correctSubscriptions)
}

#if TRACE_RESOURCES
func testMapCompose_OptimizationIsPerformed() {
let scheduler = TestScheduler(initialClock: 0)

var checked = false
let xs = scheduler.createHotObservable([
.next(150, 1),
.next(210, 0),
])

let res = scheduler.start {
xs
.map { $0 * 10 }
.map { x -> Int in
checked = true
XCTAssertTrue(Resources.numberOfMapOperators == 1)
return x + 1
}
}

let correctMessages = [
Recorded.next(210, 0 * 10 + 1),
]

let correctSubscriptions = [
Subscription(200, 1000)
]

XCTAssertTrue(checked)
XCTAssertEqual(res.events, correctMessages)
XCTAssertEqual(xs.subscriptions, correctSubscriptions)
}

func testMapCompose_OptimizationIsNotPerformed() {
let scheduler = TestScheduler(initialClock: 0)

var checked = false
let xs = scheduler.createHotObservable([
.next(150, 1),
.next(210, 0),
])

let res = scheduler.start {
xs
.map { $0 * 10 }
.filter { _ in true }
.map { x -> Int in
checked = true
XCTAssertTrue(Resources.numberOfMapOperators == 2)
return x + 1
}
}

let correctMessages = [
Recorded.next(210, 0 * 10 + 1),
]

let correctSubscriptions = [
Subscription(200, 1000)
]

XCTAssertTrue(checked)
XCTAssertEqual(res.events, correctMessages)
XCTAssertEqual(xs.subscriptions, correctSubscriptions)
}
#endif
}

0 comments on commit ba102f5

Please sign in to comment.