mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Rewrite Crypto::GetRandomValues to use typed array API
Fix mut typed_array Redundant code
This commit is contained in:
parent
b319dedda9
commit
684db8bd29
2 changed files with 5 additions and 5 deletions
|
@ -6,7 +6,6 @@ use core::nonzero::NonZero;
|
|||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::CryptoBinding;
|
||||
use dom::bindings::codegen::Bindings::CryptoBinding::CryptoMethods;
|
||||
use dom::bindings::conversions::array_buffer_view_data;
|
||||
use dom::bindings::error::{Error, Fallible};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
|
@ -46,9 +45,10 @@ impl CryptoMethods for Crypto {
|
|||
input: *mut JSObject)
|
||||
-> Fallible<NonZero<*mut JSObject>> {
|
||||
assert!(!input.is_null());
|
||||
let mut data = match array_buffer_view_data::<u8>(input) {
|
||||
Some(data) => data,
|
||||
None => {
|
||||
typedarray!(in(_cx) let mut array_buffer_view: ArrayBufferView = input);
|
||||
let mut data = match array_buffer_view.as_mut() {
|
||||
Ok(x) => x.as_mut_slice(),
|
||||
Err(_) => {
|
||||
return Err(Error::Type("Argument to Crypto.getRandomValues is not an ArrayBufferView"
|
||||
.to_owned()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue