Skip to content

Commit 7e6f12d

Browse files
committed
Replace append() to +=
1 parent ba6ba75 commit 7e6f12d

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

SwiftState/StateMachine.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
import Darwin
1010

11-
// TODO: change .append() to +=
12-
1311
// NOTE: nested type inside generic StateMachine class is not allowed in Swift 1.1
1412
// NOTE: 'public struct' didn't work since Xcode6-beta6
1513
public class StateMachineRouteID<S: StateType, E: StateEventType>
@@ -164,7 +162,7 @@ public class StateMachine<S: StateType, E: StateEventType>
164162
else {
165163
for (ev, transitionDict) in self._routes {
166164
if ev == event || ev == nil as Event {
167-
transitionDicts.append(transitionDict)
165+
transitionDicts += [transitionDict]
168166
break
169167
}
170168
}
@@ -273,21 +271,21 @@ public class StateMachine<S: StateType, E: StateEventType>
273271
var transitions: [Transition] = []
274272

275273
// anywhere
276-
transitions.append(nil => nil)
274+
transitions += [nil => nil]
277275

278276
// exit
279277
if transition.fromState != nil as State {
280-
transitions.append(transition.fromState => nil)
278+
transitions += [transition.fromState => nil]
281279
}
282280

283281
// entry
284282
if transition.toState != nil as State {
285-
transitions.append(nil => transition.toState)
283+
transitions += [nil => transition.toState]
286284
}
287285

288286
// specific
289287
if (transition.fromState != nil as State) && (transition.toState != nil as State) {
290-
transitions.append(transition)
288+
transitions += [transition]
291289
}
292290

293291
return transitions
@@ -661,7 +659,7 @@ public class StateMachine<S: StateType, E: StateEventType>
661659

662660
for route in chain.routes {
663661
let routeID = self.addRoute(route)
664-
routeIDs.append(routeID)
662+
routeIDs += [routeID]
665663
}
666664

667665
let handlerID = self.addChainHandler(chain, handler: handler)
@@ -741,7 +739,7 @@ public class StateMachine<S: StateType, E: StateEventType>
741739
}
742740
}
743741
}
744-
handlerIDs.append(handlerID)
742+
handlerIDs += [handlerID]
745743

746744
// increment chainingCount on every route
747745
for route in chain.routes {
@@ -763,7 +761,7 @@ public class StateMachine<S: StateType, E: StateEventType>
763761
}
764762
}
765763
}
766-
handlerIDs.append(handlerID)
764+
handlerIDs += [handlerID]
767765
}
768766

769767
// increment allCount (+ invoke chainErrorHandler) on any routes
@@ -783,7 +781,7 @@ public class StateMachine<S: StateType, E: StateEventType>
783781
}
784782
}
785783
}
786-
handlerIDs.append(handlerID)
784+
handlerIDs += [handlerID]
787785

788786
// invoke chainHandler on last route
789787
let lastRoute = chain.routes.last!
@@ -802,7 +800,7 @@ public class StateMachine<S: StateType, E: StateEventType>
802800
}
803801
}
804802
}
805-
handlerIDs.append(handlerID)
803+
handlerIDs += [handlerID]
806804

807805
let bundledHandlerID = HandlerID(bundledHandlerIDs: handlerIDs)
808806

@@ -818,7 +816,7 @@ public class StateMachine<S: StateType, E: StateEventType>
818816
var routes: [Route] = []
819817
for transition in transitions {
820818
let route = Route(transition: transition, condition: condition)
821-
routes.append(route)
819+
routes += [route]
822820
}
823821

824822
return self.addRouteEvent(event, routes: routes)
@@ -834,7 +832,7 @@ public class StateMachine<S: StateType, E: StateEventType>
834832
var routeIDs: [RouteID] = []
835833
for route in routes {
836834
let routeID = self._addRoute(route, forEvent: event)
837-
routeIDs.append(routeID)
835+
routeIDs += [routeID]
838836
}
839837

840838
return routeIDs

SwiftState/StateRoute.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public struct StateRoute<S: StateType>
3535
public func toRouteChain() -> StateRouteChain<State>
3636
{
3737
var routes: [StateRoute<State>] = []
38-
routes.append(self)
38+
routes += [self]
3939
return StateRouteChain(routes: routes)
4040
}
4141
}

SwiftState/StateRouteChain.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public struct StateRouteChain<S: StateType>
2525
{
2626
var routes: [Route] = []
2727
for transition in transitionChain.transitions {
28-
routes.append(Route(transition: transition, condition: condition))
28+
routes += [Route(transition: transition, condition: condition)]
2929
}
3030
self.routes = routes
3131
}
@@ -48,7 +48,7 @@ public struct StateRouteChain<S: StateType>
4848
let lastToState = self.routes.last!.transition.toState
4949
let newRoute = Route(transition: lastToState => state, condition: condition)
5050

51-
self.routes.append(newRoute)
51+
self.routes += [newRoute]
5252
}
5353

5454
public func toTransitionChain() -> TransitionChain

SwiftState/StateTransitionChain.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public struct StateTransitionChain<S: StateType>
3737
var transitions: [Transition] = []
3838

3939
for i in 0..<states.count-1 {
40-
transitions.append(states[i] => states[i+1])
40+
transitions += [states[i] => states[i+1]]
4141
}
4242

4343
return transitions
@@ -65,7 +65,7 @@ public struct StateTransitionChain<S: StateType>
6565

6666
mutating public func append(state: State)
6767
{
68-
self.states.append(state)
68+
self.states += [state]
6969
}
7070

7171
public func toRouteChain() -> StateRouteChain<State>

0 commit comments

Comments
 (0)