Skip to content
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

Create Data using String.utf8 instead of NSString.data(using:) #166

Merged
merged 1 commit into from
Feb 6, 2019

Conversation

pushkarnk
Copy link
Contributor

@pushkarnk pushkarnk commented Feb 5, 2019

We have string.data(using:) to create Data in a handful of places. This will be sub-optimal given that it implicitly goes through NSString, which is currently a known performance bottleneck in Swift 5.

This is on the lines of Kitura/Kitura#1395

@codecov-io
Copy link

codecov-io commented Feb 5, 2019

Codecov Report

Merging #166 into master will increase coverage by 0.02%.
The diff coverage is 40%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #166      +/-   ##
==========================================
+ Coverage   66.84%   66.87%   +0.02%     
==========================================
  Files          20       20              
  Lines        1300     1298       -2     
==========================================
- Hits          869      868       -1     
+ Misses        431      430       -1
Flag Coverage Δ
#KituraNet 66.87% <40%> (+0.02%) ⬆️
Impacted Files Coverage Δ
...urces/KituraNet/FastCGI/FastCGIServerRequest.swift 0% <0%> (ø) ⬆️
Sources/KituraNet/HTTP/HTTPServerRequest.swift 72.67% <100%> (ø) ⬆️
Sources/KituraNet/ClientRequest.swift 68.37% <33.33%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe5db77...fed5f1c. Read the comment docs.

@@ -55,7 +55,7 @@ public class FastCGIServerRequest: ServerRequest {
/// The URL from the request in UTF-8 form
/// This contains just the path and query parameters starting with '/'
/// Use 'urlURL' for the full URL
public var url: Data { return requestUri?.data(using: .utf8) ?? Data() }
public var url: Data { return Data(urlURL.absoluteString.utf8) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed to use urlURL rather than requestUri? The comment above says they are different.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ianpartridge Thanks for finding this. I've fixed it.

@pushkarnk pushkarnk merged commit 9f9ecfe into Kitura:master Feb 6, 2019
@pushkarnk pushkarnk deleted the data-from-utf8view branch May 26, 2020 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants