1
1
// Successful match FSPaths
2
- private let fsPathSuccess = #"""
2
+ private let pathSuccess = #"""
3
3
./First/Second/Third/some/really/long/content.extension/more/stuff/OptionLeft
4
4
./First/Second/Third/some/really/long/content.extension/more/stuff/OptionRight
5
5
./First/Second/PrefixThird/some/really/long/content.extension/more/stuff/OptionLeft
@@ -10,7 +10,7 @@ private let fsPathSuccess = #"""
10
10
//
11
11
// We will have far more failures than successful matches by interspersing
12
12
// this whole list between each success
13
- private let fsPathFailure = #"""
13
+ private let pathFailure = #"""
14
14
a/b/c
15
15
/smol/path
16
16
/a/really/long/path/that/is/certainly/stored/out/of/line
@@ -28,24 +28,43 @@ a/b/c
28
28
./First/Second/PrefixThird/some/really/long/content/more/stuff/OptionRight
29
29
"""#
30
30
31
+ private func listify( _ s: String ) -> [ String ] {
32
+ s. split ( whereSeparator: { $0. isNewline } ) . map { String ( $0) }
33
+ }
34
+
35
+ private let pathSuccessList : [ String ] = { listify ( pathSuccess) } ( )
36
+ private let pathFailureList : [ String ] = { listify ( pathFailure) } ( )
37
+
38
+ private func scale( _ input: [ String ] ) -> [ String ] {
39
+ let threshold = 1_000
40
+ var result = input
41
+ while result. count < threshold {
42
+ result. append ( contentsOf: input)
43
+ }
44
+ return result
45
+ }
46
+
31
47
extension Inputs {
32
48
static let fsPathsList : [ String ] = {
33
- var result : [ String ] = [ ]
34
- let failures : [ String ] = fsPathFailure. split ( whereSeparator: { $0. isNewline } ) . map { String ( $0) }
35
- result. append ( contentsOf: failures)
49
+ var result = pathFailureList
50
+ result. append ( contentsOf: pathFailureList)
36
51
37
- for success in fsPathSuccess . split ( whereSeparator : { $0 . isNewline } ) {
52
+ for success in pathSuccessList {
38
53
result. append ( String ( success) )
39
- result. append ( contentsOf: failures)
54
+ result. append ( contentsOf: pathFailureList)
55
+ result. append ( contentsOf: pathFailureList)
40
56
}
41
57
42
58
// Scale result up a bit
43
- result. append ( contentsOf: result)
44
- result. append ( contentsOf: result)
45
- result. append ( contentsOf: result)
46
- result. append ( contentsOf: result)
59
+ return scale ( result)
60
+
61
+ } ( )
47
62
48
- return result
63
+ static let fsPathsNotFoundList : [ String ] = {
64
+ scale ( pathFailureList)
65
+ } ( )
49
66
67
+ static let fsPathsFoundList : [ String ] = {
68
+ scale ( pathFailureList)
50
69
} ( )
51
70
}
0 commit comments