Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit604bd05

Browse files
committed
update memoryview eq
1 parent1e97d72 commit604bd05

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

‎vm/src/obj/objmemory.rs

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -610,33 +610,43 @@ impl PyMemoryView {
610610
if zelf.released.load(){
611611
returnOk(false);
612612
}
613+
613614
let options_cmp = |a:&BufferOptions,b:&BufferOptions| ->bool{
614615
a.len == b.len && a.itemsize == b.itemsize
615616
};
616-
// TODO: fast pass for contiguous buffer
617-
match other.clone().downcast::<PyMemoryView>(){
618-
Ok(other) =>{
619-
ifoptions_cmp(&zelf.options,&other.options){
620-
let a =Self::tolist(zelf.clone(), vm)?;
621-
let b =Self::tolist(other, vm)?;
622-
if vm.bool_eq(a.as_object(), b.as_object())?{
623-
returnOk(true);
624-
}
625-
}
617+
618+
let other =try_buffer_from_object(vm, other)?;
619+
620+
if !options_cmp(&zelf.options,&other.get_options()){
621+
returnOk(false);
622+
}
623+
624+
let a_guard;
625+
let a_vec;
626+
let a =match zelf.as_contiguous(){
627+
Some(bytes) =>{
628+
a_guard = bytes;
629+
&*a_guard
626630
}
627-
Err(other) =>{
628-
ifletOk(buffer) =try_buffer_from_object(vm,&other){
629-
let options = buffer.get_options();
630-
// FIXME
631-
ifoptions_cmp(&zelf.options,&options)
632-
&&(**(Self::tobytes(zelf.clone(), vm)?) ==*buffer.obj_bytes())
633-
{
634-
returnOk(true);
635-
}
636-
}
631+
None =>{
632+
a_vec = zelf.to_contiguous();
633+
a_vec.as_slice()
637634
}
638-
}
639-
Ok(false)
635+
};
636+
let b_guard;
637+
let b_vec;
638+
let b =match other.as_contiguous(){
639+
Some(bytes) =>{
640+
b_guard = bytes;
641+
&*b_guard
642+
}
643+
None =>{
644+
b_vec = other.to_contiguous();
645+
b_vec.as_slice()
646+
}
647+
};
648+
649+
Ok(a == b)
640650
}
641651
}
642652

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp