Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Usbergo committed May 12, 2016
1 parent 235b7c0 commit e941907
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 33 deletions.
10 changes: 7 additions & 3 deletions Render/BaseComponentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ public class ComponentView: BaseComponentView {

// runs its own configuration
self.internalStore.configureClosure?()

// This shouldn't be necessary since render is performed on the
// root after the new view hiearchy is installed.
// This could lead to a 50% perf. improvement for render.
self._root?.render(size)

let startTime = CFAbsoluteTimeGetCurrent()
Expand All @@ -224,15 +228,15 @@ public class ComponentView: BaseComponentView {
debugRenderTime("\(self.dynamicType).renderComponent", startTime: startTime)
}

// the view never rendered
// The view never rendered
guard let old = self._root where old.renderedView != nil else {
self._root = self.construct()
return
}

var new = self.construct()

//diff between new and old
// Diff between new and old
func diff(old: ComponentNodeType, new: ComponentNodeType) -> ComponentNodeType {

old.prepareForUnmount()
Expand All @@ -246,7 +250,7 @@ public class ComponentView: BaseComponentView {
children.append(diff(o, new: n))
}

//adds the new one
// Adds the new one
if new.children.count > old.children.count {
for i in old.children.count..<new.children.count {
children.append(new.children[i])
Expand Down
21 changes: 20 additions & 1 deletion Render/ComponentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,26 @@
// Render
//
// Created by Alex Usbergo on 21/04/16.
// Copyright © 2016 Alex Usbergo. All rights reserved.
//
// Copyright (c) 2016 Alex Usbergo.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import UIKit
Expand Down
7 changes: 0 additions & 7 deletions Render/ComponentTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
// Render
//
// Created by Alex Usbergo on 07/05/16.
// Copyright © 2016 Alex Usbergo. All rights reserved.
//
//
// ComponentCollectionView.swift
// Render
//
// Created by Alex Usbergo on 27/04/16.
//
// Copyright (c) 2016 Alex Usbergo.
//
Expand Down
4 changes: 2 additions & 2 deletions Render/LCS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ public extension Array where Element: Equatable {
}
}

internal struct MemoizedSequenceComparison<T: Equatable> {
private struct MemoizedSequenceComparison<T: Equatable> {

static func buildTable(x: [T], _ y: [T], _ n: Int, _ m: Int) -> [[Int]] {
private static func buildTable(x: [T], _ y: [T], _ n: Int, _ m: Int) -> [[Int]] {
var table = Array(count: n + 1, repeatedValue: Array(count: m + 1, repeatedValue: 0))
for i in 0...n {
for j in 0...m {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../Render/ComponentTableView.swift"
timestampString = "484572800.893518"
timestampString = "484739185.740011"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "76"
endingLineNumber = "76"
startingLineNumber = "69"
endingLineNumber = "69"
landmarkName = "init(frame:style:)"
landmarkType = "5">
</BreakpointContent>
Expand Down Expand Up @@ -311,13 +311,13 @@
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../Render/ComponentCollectionView.swift"
timestampString = "484737211.79403"
filePath = "RenderTodoDemo/ViewController.swift"
timestampString = "484736940.171401"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "121"
endingLineNumber = "121"
landmarkName = "renderComponent(_:)"
startingLineNumber = "45"
endingLineNumber = "45"
landmarkName = "viewDidLayoutSubviews()"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
Expand All @@ -327,29 +327,125 @@
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../Render/ComponentCollectionView.swift"
timestampString = "484737211.79403"
filePath = "../Render/BaseComponentView.swift"
timestampString = "484745256.027751"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "121"
endingLineNumber = "121"
startingLineNumber = "304"
endingLineNumber = "304"
landmarkName = "renderComponent(_:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "RenderTodoDemo/ViewController.swift"
timestampString = "484736940.171401"
timestampString = "484739232.67027"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "45"
endingLineNumber = "45"
landmarkName = "viewDidLayoutSubviews()"
startingLineNumber = "52"
endingLineNumber = "52"
landmarkName = "didSelectItem(_:indexPath:listComponent:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "RenderTodoDemo/ViewController.swift"
timestampString = "484739299.094581"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "62"
endingLineNumber = "62"
landmarkName = "didSelectItem(_:indexPath:listComponent:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "RenderTodoDemo/ViewController.swift"
timestampString = "484739306.211563"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "69"
endingLineNumber = "69"
landmarkName = "didSelectItem(_:indexPath:listComponent:)"
landmarkType = "5">
<Locations>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "RenderTodoDemo.ViewController.didSelectItem (Render.ListComponentItemType, indexPath : __ObjC.NSIndexPath, listComponent : Render.ComponentViewType) -&gt; ()"
moduleName = "RenderTodoDemo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/alexusbergo/Desktop/swift/Render/RenderTodoDemo/RenderTodoDemo/ViewController.swift"
timestampString = "484739316.262712"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "69"
endingLineNumber = "69"
offsetFromSymbolStart = "1300">
</Location>
<Location
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "RenderTodoDemo.ViewController.(didSelectItem (Render.ListComponentItemType, indexPath : __ObjC.NSIndexPath, listComponent : Render.ComponentViewType) -&gt; ()).(closure #2)"
moduleName = "RenderTodoDemo"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/alexusbergo/Desktop/swift/Render/RenderTodoDemo/RenderTodoDemo/ViewController.swift"
timestampString = "484739316.262928"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "70"
endingLineNumber = "70"
offsetFromSymbolStart = "23">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "RenderTodoDemo/ViewController.swift"
timestampString = "484739347.180149"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "63"
endingLineNumber = "63"
landmarkName = "didSelectItem(_:indexPath:listComponent:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "RenderTodoDemo/ViewController.swift"
timestampString = "484739348.495931"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "70"
endingLineNumber = "70"
landmarkName = "didSelectItem(_:indexPath:listComponent:)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
Expand Down
2 changes: 1 addition & 1 deletion RenderTodoDemo/RenderTodoDemo/AlbumComponentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension Album: ComponentStateTypeUniquing {
}
}

class AlbumComponentView: ComponentView {
class AlbumComponentView: StaticComponentView {

// If the component is used as list item it should be registered
// as prototype for the infra.
Expand Down
2 changes: 1 addition & 1 deletion RenderTodoDemo/RenderTodoDemo/VideoComponentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension Video: ComponentStateTypeUniquing {
}
}

class VideoComponentView: ComponentView {
class VideoComponentView: StaticComponentView {

// If the component is used as list item it should be registered
// as prototype for the infra.
Expand Down
1 change: 0 additions & 1 deletion RenderTodoDemo/RenderTodoDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ extension ViewController: ListComponentItemDelegate {

//we want to remove a video
} else if let videoItem = item as? ListComponentItem<VideoComponentView, Video> {

self.albums = self.albums.filter({
guard let otherVideo = $0 as? ListComponentItem<VideoComponentView, Video> else { return true }
return otherVideo.state != videoItem.state
Expand Down

0 comments on commit e941907

Please sign in to comment.