Speed up strippingHTML dramatically by calling reserveCharacters with maxCharacters when possible, which is generally much less than the count of preflight characters.
This commit is contained in:
parent
75e525380b
commit
3b17e77358
@ -223,7 +223,12 @@ public extension String {
|
|||||||
preflight = preflight.removingTagAndContents("style")
|
preflight = preflight.removingTagAndContents("style")
|
||||||
|
|
||||||
var s = String()
|
var s = String()
|
||||||
|
if let maxCharacters {
|
||||||
|
s.reserveCapacity(maxCharacters)
|
||||||
|
}
|
||||||
|
else {
|
||||||
s.reserveCapacity(preflight.count)
|
s.reserveCapacity(preflight.count)
|
||||||
|
}
|
||||||
var lastCharacterWasSpace = false
|
var lastCharacterWasSpace = false
|
||||||
var charactersAdded = 0
|
var charactersAdded = 0
|
||||||
var level = 0
|
var level = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user