-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Benchmarks] Update benchmarks to Swift 4 #14623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ let charToString = { (c: Character) -> String in String(c) } | |
let charToInt = stringToInt • charToString | ||
|
||
func sum<S: Sequence>(_ nums: S)->S.Iterator.Element where S.Iterator.Element: FixedWidthInteger { | ||
return nums.reduce(0) { $0.0 + $0.1 } | ||
return nums.reduce(0, +) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That'll start failing eventually.. I think. When the SE-110 is reconsidered again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dislike that change so this is a pro not a con AFAIAC :), but the reason I changed it is cos it's now |
||
} | ||
|
||
func reverse<C: LazyCollectionProtocol>( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,23 +22,15 @@ public let StringMatch = BenchmarkInfo( | |
runFunction: run_StringMatch, | ||
tags: [.validation, .api, .String]) | ||
|
||
extension String { | ||
@inline(__always) | ||
func dropFirst(_ n: Int = 1) -> String { | ||
let startIndex = self.index(self.startIndex, offsetBy: n) | ||
return self[startIndex ..< self.endIndex] | ||
} | ||
} | ||
|
||
/* match: search for regexp anywhere in text */ | ||
func match(regexp: String, text: String) -> Bool { | ||
if regexp.first == "^" { | ||
return matchHere(regexp.dropFirst(), text) | ||
return matchHere(regexp.dropFirst(), text[...]) | ||
} | ||
|
||
var idx = text.startIndex | ||
while true { // must look even if string is empty | ||
if matchHere(regexp, text[idx..<text.endIndex]) { | ||
if matchHere(regexp[...], text[idx..<text.endIndex]) { | ||
return true | ||
} | ||
guard idx != text.endIndex else { break } | ||
|
@@ -50,7 +42,7 @@ func match(regexp: String, text: String) -> Bool { | |
} | ||
|
||
/* matchhere: search for regexp at beginning of text */ | ||
func matchHere(_ regexp: String, _ text: String) -> Bool { | ||
func matchHere(_ regexp: Substring, _ text: Substring) -> Bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Funny.. One would think that this would speed things up a little.
|
||
if regexp.isEmpty { | ||
return true | ||
} | ||
|
@@ -71,7 +63,7 @@ func matchHere(_ regexp: String, _ text: String) -> Bool { | |
} | ||
|
||
/* matchstar: search for c*regexp at beginning of text */ | ||
func matchStar(_ c: Character, _ regexp: String, _ text: String) -> Bool { | ||
func matchStar(_ c: Character, _ regexp: Substring, _ text: Substring) -> Bool { | ||
var idx = text.startIndex | ||
while true { /* a * matches zero or more instances */ | ||
if matchHere(regexp, text[idx..<text.endIndex]) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing optimizer's job ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah, suppressing an exclusive access warning