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

CFString refactor / cleanup #220

Merged
merged 2 commits into from May 29, 2018
Merged

CFString refactor / cleanup #220

merged 2 commits into from May 29, 2018

Conversation

@TimNN
Copy link
Contributor

TimNN commented May 29, 2018

This pull request:

  • removes two unnecessary casts (from CFIndex to usize and back again)
  • extracts the to rust string conversion: instead of doing it on-the-fly in the Display implementation (and thus only supporting the indirect ToString way to get a rust string from a CFString, which always allocates) this implements From<&CFString> for Cow<str> allowing everyone the possibility of avoiding an allocation if the CFString is already formatted in UTF-8.

Rebase of #76 (note to self: next time, re-open first, then push).

cc @jdm


This change is Reviewable

@TimNN TimNN mentioned this pull request May 29, 2018
@jdm
Copy link
Member

jdm commented May 29, 2018

@bors-servo
Copy link
Contributor

bors-servo commented May 29, 2018

📌 Commit dd3a4b5 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented May 29, 2018

Testing commit dd3a4b5 with merge 2aac8fb...

bors-servo added a commit that referenced this pull request May 29, 2018
CFString refactor / cleanup

This pull request:
- removes two unnecessary casts (from `CFIndex` to `usize` and back again)
- extracts the to rust string conversion: instead of doing it on-the-fly in the `Display` implementation (and thus only supporting the indirect `ToString` way to get a rust string from a `CFString`, which _always_ allocates) this implements `From<&CFString> for Cow<str>` allowing everyone the possibility of avoiding an allocation if the `CFString` is already formatted in UTF-8.

Rebase of #76 (note to self: next time, re-open first, then push).

cc @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/220)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 29, 2018

☀️ Test successful - status-travis
Approved by: jdm
Pushing 2aac8fb to master...

@bors-servo bors-servo merged commit dd3a4b5 into servo:master May 29, 2018
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.