diff --git a/.github/fixed_podspecs/Dwifft.podspec b/.github/fixed_podspecs/Dwifft.podspec deleted file mode 100644 index 26df1a6..0000000 --- a/.github/fixed_podspecs/Dwifft.podspec +++ /dev/null @@ -1,20 +0,0 @@ -Pod::Spec.new do |s| - s.name = 'Dwifft' - s.version = '0.9' - s.license = 'MIT' - s.summary = 'Swift Diff' - s.homepage = 'https://github.com/jflinter/Dwifft' - s.social_media_url = 'http://twitter.com/jflinter' - s.author = 'Jack Flintermann' - s.source = { git: 'https://github.com/jflinter/Dwifft.git', tag: s.version } - - s.swift_version = '5.0' - - s.ios.deployment_target = '12.0' - s.tvos.deployment_target = '12.0' - s.osx.deployment_target = '10.13' - - s.source_files = 'Dwifft/*.swift' - - s.requires_arc = true -end diff --git a/Examples/Podfile.lock b/Examples/Podfile.lock index 1dc597f..6413c60 100644 --- a/Examples/Podfile.lock +++ b/Examples/Podfile.lock @@ -1,11 +1,8 @@ PODS: - - Dwifft (0.9) - Nimble (12.3.0) - Quick (7.3.0) - - SimpleSource (3.0.0): - - Dwifft (~> 0.9.0) + - SimpleSource (3.0.0) - SimpleSource/Tests (3.0.0): - - Dwifft (~> 0.9.0) - Nimble (~> 12.0) - Quick (~> 7.0) - SwiftyJSON (5.0.1) @@ -17,7 +14,6 @@ DEPENDENCIES: SPEC REPOS: trunk: - - Dwifft - Nimble - Quick - SwiftyJSON @@ -27,10 +23,9 @@ EXTERNAL SOURCES: :path: ".." SPEC CHECKSUMS: - Dwifft: 42912068ed2a8146077d1a1404df18625bd086e1 Nimble: f8a8219d16f176429b951e8f7e72df5c23ceddc0 Quick: d32871931c05547cb4e0bc9009d66a18b50d8558 - SimpleSource: 14b1bd2028a07d7b2a71433bed85f03ca33deb37 + SimpleSource: 611bfe53fe55132415a3c72a9a0126f9aa846d8b SwiftyJSON: 2f33a42c6fbc52764d96f13368585094bfd8aa5e PODFILE CHECKSUM: a5deddba5204624da3222bdb26450e64fabfabc5 diff --git a/SimpleSource.podspec b/SimpleSource.podspec index e314bd7..357388c 100644 --- a/SimpleSource.podspec +++ b/SimpleSource.podspec @@ -9,7 +9,6 @@ Pod::Spec.new do |s| s.swift_version = '5.7' s.source = { :git => 'https://github.com/Squarespace/simple-source.git', :tag => s.version } s.source_files = 'Sources/**/*.{h,m,swift}' - s.dependency 'Dwifft', '~> 0.9.0' s.test_spec 'Tests' do |test_spec| test_spec.resource = 'Tests/Model/*.xcdatamodeld' diff --git a/Sources/Utils/Diff.swift b/Sources/Utils/Diff.swift index 7dda937..a413c5a 100644 --- a/Sources/Utils/Diff.swift +++ b/Sources/Utils/Diff.swift @@ -1,5 +1,4 @@ import Foundation -import Dwifft private struct WrappedIdentifiableSection { private let value: T @@ -38,15 +37,13 @@ struct Diff { let oldSectionIdentifiers = oldData.map { $0.sectionIdentifier } let newSectionIdentifiers = newData.map { $0.sectionIdentifier } - - let sectionsDiff = Dwifft.diff(oldSectionIdentifiers, newSectionIdentifiers) - sectionsDiff.forEach { step in - switch step { - case .insert: - insertedSections.insert(step.idx) - case .delete: - deletedSections.insert(step.idx) + newSectionIdentifiers.difference(from: oldSectionIdentifiers).forEach { change in + switch change { + case let .remove(offset, _, _): + deletedSections.insert(offset) + case let .insert(offset, _, _): + insertedSections.insert(offset) } } @@ -76,20 +73,17 @@ struct Diff { .map { IndexPath(item: $0.offset, section: sectionIndex) } } else { // Calculate a diff to transform the old section items into the new section items. No in-place updates will be emitted. - Dwifft.diff(oldSection.items, newSection.items) - .forEach { step in - switch step { - case .insert: - let indexPath = IndexPath(item: step.idx, section: sectionIndex) - insertedRows.append(indexPath) - case .delete: - let indexPath = IndexPath(item: step.idx, section: oldSectionIndex) - deletedRows.append(indexPath) - } + newSection.items.difference(from: oldSection.items).forEach { change in + switch change { + case let .remove(offset, _, _): + deletedRows.append(.init(item: offset, section: oldSectionIndex)) + case let .insert(offset, _, _): + insertedRows.append(.init(item: offset, section: sectionIndex)) } + } } } - + return .delta( insertedSections: insertedSections, updatedSections: IndexSet(),