diff --git a/Example/SwiftSoup/ViewController.swift b/Example/SwiftSoup/ViewController.swift
index 19354d8..d76c539 100644
--- a/Example/SwiftSoup/ViewController.swift
+++ b/Example/SwiftSoup/ViewController.swift
@@ -14,6 +14,8 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
+ //testPerformanceDiv()
+ testSite()
}
override func didReceiveMemoryWarning() {
@@ -29,6 +31,74 @@ class ViewController: UIViewController {
return doc
}
+ func testPerformanceDiv() {
+ let h: String = "\n" +
+ "\n" +
+ "
\n" +
+ " \n" +
+ "
"\"><>&\"\n" +
+ "
"\"><>&\"\n" +
+ "
"\"><>&\"\n" +
+ "
"\"><>&\"\n" +
+ "
"\"><>&\"\n" +
+ "
"\"><>&\"\n" +
+ "
"\"><>&\"\n" +
+ "
"\"><>&\"\n" +
+ "
"\"><>&\"\n" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ " bar\n" +
+ " \n" +
+ ""
+ let doc: Document = try! SwiftSoup.parse(h);
+ do {
+ for _ in 0...100000{
+ _ = try doc.select("div");
+ }
+ }
+ catch {
+ }
+ }
+
+ func testSite()
+ {
+ let myURLString = "http://apple.com"
+ guard let myURL = URL(string: myURLString) else {
+ print("Error: \(myURLString) doesn't seem to be a valid URL")
+ return
+ }
+ let html = try! String(contentsOf: myURL, encoding: .utf8)
+ let doc: Document = try! SwiftSoup.parse(html)
+
+ do {
+ for _ in 0...100{
+ _ = try doc.text()
+ }
+ }
+ catch {
+ print("Error")
+ }
+ }
+
}
diff --git a/Sources/TextNode.swift b/Sources/TextNode.swift
index 1489fe2..fbab800 100644
--- a/Sources/TextNode.swift
+++ b/Sources/TextNode.swift
@@ -146,7 +146,7 @@ open class TextNode : Node {
}
static open func lastCharIsWhitespace(_ sb: StringBuilder)->Bool {
- return sb.length != 0 && sb.toString().charAt(sb.length - 1) == " ";
+ return sb.toString().characters.last == " ";
}
// attribute fiddling. create on first access.
diff --git a/SwiftSoup.podspec b/SwiftSoup.podspec
index e51a4d0..b32b3f1 100644
--- a/SwiftSoup.podspec
+++ b/SwiftSoup.podspec
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = 'SwiftSoup'
- s.version = '1.0.1'
+ s.version = '1.0.2'
s.summary = 'Swift HTML Parser.'
# This description is used to generate tags and improve search results.
diff --git a/SwiftSoup.xcodeproj/xcshareddata/xcbaselines/8CE4181E1DAA54A900240B42.xcbaseline/9F80FB9B-4E37-45A8-BFE8-9AF36737A6F3.plist b/SwiftSoup.xcodeproj/xcshareddata/xcbaselines/8CE4181E1DAA54A900240B42.xcbaseline/9F80FB9B-4E37-45A8-BFE8-9AF36737A6F3.plist
new file mode 100644
index 0000000..8572677
--- /dev/null
+++ b/SwiftSoup.xcodeproj/xcshareddata/xcbaselines/8CE4181E1DAA54A900240B42.xcbaseline/9F80FB9B-4E37-45A8-BFE8-9AF36737A6F3.plist
@@ -0,0 +1,22 @@
+
+
+
+
+ classNames
+
+ SwiftSoupTests
+
+ testPerformanceDiv()
+
+ com.apple.XCTPerformanceMetric_WallClockTime
+
+ baselineAverage
+ 36.859
+ baselineIntegrationDisplayName
+ Local Baseline
+
+
+
+
+
+
diff --git a/SwiftSoup.xcodeproj/xcshareddata/xcbaselines/8CE4181E1DAA54A900240B42.xcbaseline/Info.plist b/SwiftSoup.xcodeproj/xcshareddata/xcbaselines/8CE4181E1DAA54A900240B42.xcbaseline/Info.plist
index 2e37db7..7745749 100644
--- a/SwiftSoup.xcodeproj/xcshareddata/xcbaselines/8CE4181E1DAA54A900240B42.xcbaseline/Info.plist
+++ b/SwiftSoup.xcodeproj/xcshareddata/xcbaselines/8CE4181E1DAA54A900240B42.xcbaseline/Info.plist
@@ -4,6 +4,37 @@
runDestinationsByUUID
+ 9F80FB9B-4E37-45A8-BFE8-9AF36737A6F3
+
+ localComputer
+
+ busSpeedInMHz
+ 100
+ cpuCount
+ 1
+ cpuKind
+ Intel Core i7
+ cpuSpeedInMHz
+ 3100
+ logicalCPUCoresPerPackage
+ 4
+ modelCode
+ MacBookPro12,1
+ physicalCPUCoresPerPackage
+ 2
+ platformIdentifier
+ com.apple.platform.macosx
+
+ targetArchitecture
+ x86_64
+ targetDevice
+
+ modelCode
+ iPhone7,2
+ platformIdentifier
+ com.apple.platform.iphonesimulator
+
+
F9553B46-8F24-4C2B-8A1E-8CC5535D12E1
localComputer
diff --git a/Tests/textTests/SwiftSoupTests.swift b/Tests/textTests/SwiftSoupTests.swift
index 5ee7da1..2e64e21 100644
--- a/Tests/textTests/SwiftSoupTests.swift
+++ b/Tests/textTests/SwiftSoupTests.swift
@@ -29,6 +29,78 @@ class SwiftSoupTests: XCTestCase {
super.tearDown()
}
-
-
+ private func createHtmlDocument(_ charset: String)->Document {
+ let doc: Document = Document.createShell("");
+ try! doc.head()?.appendElement("meta").attr("charset", charset);
+ try! doc.head()?.appendElement("meta").attr("name", "charset").attr("content", charset);
+ return doc;
+ }
+ //average: 58.562,
+ //passed (586.015 seconds)
+// func testPerformanceExample() {
+// let h: String = "\n" +
+// "\n" +
+// " \n" +
+// " \n" +
+// "
"\"><>&\"\n" +
+// "
"\"><>&\"\n" +
+// "
"\"><>&\"\n" +
+// "
"\"><>&\"\n" +
+// "
"\"><>&\"\n" +
+// "
"\"><>&\"\n" +
+// "
"\"><>&\"\n" +
+// "
"\"><>&\"\n" +
+// "
"\"><>&\"\n" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// "" +
+// " bar\n" +
+// " \n" +
+// ""
+// self.measure {
+// do {
+// for _ in 0...1000{
+// let doc: Document = try! SwiftSoup.parse(h);
+// doc.updateMetaCharsetElement(true);
+// try doc.charset(String.Encoding.isoLatin2);
+//
+// _ = try doc.toString()
+//
+// let selectedElement: Element = try doc.select("meta[charset]").first()!;
+// _ = doc.charset().displayName()
+// _ = try selectedElement.attr("charset")
+// _ = doc.outputSettings().charset()
+// _ = try doc.select("div")
+// _ = try doc.cssSelector()
+// _ = doc.firstElementSibling()
+// _ = try doc.getElementsByAttributeValueContaining("key", "mm")
+// _ = selectedElement.children()
+// _ = try selectedElement.after(" c ")
+// _ = try selectedElement.select("dd")
+// }
+// }
+// catch {
+// }
+// }
+// }
+ //passed (390.343 seconds).
+
}