-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the unnecessary copy in
Blob::new
(#152)
* Remove the unnecessary copy in `Blob::new` Fixes #150 * Various changes First, I made `new_` take a `BlobContents`, to move the unsafety inside the function to make it easier to check. Then I got rid of it in favour of `new_with_options` since the signature was the same. That broke `File::slice`, though, since it passed a `Blob` for `contents`, which didn't implement `BlobContents`. Since having `Blob` implement `BlobContents` is useful anyway, I decided to do that and simplify things. I then also implemented `BlobContents` for `JsString`, so that if you already have one you don't have to go via `&str`. I then noticed that `Blob` encoded JS strings as UTF-8, which meant that passing `&str` to `new Blob()` by converting it to a JS string meant converting it into UTF-16 and then back to UTF-8. So, I made it instead pass it as bytes, since it's already correctly encoded. * lint
- Loading branch information
1 parent
ea1a40c
commit b7ea958
Showing
1 changed file
with
40 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters