prevent unconditional cloning of results

This commit is contained in:
Kunal Mohan 2020-08-27 21:18:25 +05:30
parent d3d006dea3
commit 85b6bbb33a

View file

@ -474,7 +474,7 @@ impl<'a> WGPU<'a> {
)) ))
.map_err(|e| format!("{:?}", e)) .map_err(|e| format!("{:?}", e))
}; };
self.encoder_record_error(command_encoder_id, result.clone()); self.encoder_record_error(command_encoder_id, &result);
self.send_result(device_id, scope_id, result); self.send_result(device_id, scope_id, result);
}, },
WebGPURequest::CopyBufferToBuffer { WebGPURequest::CopyBufferToBuffer {
@ -494,7 +494,7 @@ impl<'a> WGPU<'a> {
destination_offset, destination_offset,
size size
)); ));
self.encoder_record_error(command_encoder_id, result); self.encoder_record_error(command_encoder_id, &result);
}, },
WebGPURequest::CopyBufferToTexture { WebGPURequest::CopyBufferToTexture {
command_encoder_id, command_encoder_id,
@ -509,7 +509,7 @@ impl<'a> WGPU<'a> {
&destination, &destination,
&copy_size &copy_size
)); ));
self.encoder_record_error(command_encoder_id, result); self.encoder_record_error(command_encoder_id, &result);
}, },
WebGPURequest::CopyTextureToBuffer { WebGPURequest::CopyTextureToBuffer {
command_encoder_id, command_encoder_id,
@ -524,7 +524,7 @@ impl<'a> WGPU<'a> {
&destination, &destination,
&copy_size &copy_size
)); ));
self.encoder_record_error(command_encoder_id, result); self.encoder_record_error(command_encoder_id, &result);
}, },
WebGPURequest::CopyTextureToTexture { WebGPURequest::CopyTextureToTexture {
command_encoder_id, command_encoder_id,
@ -539,7 +539,7 @@ impl<'a> WGPU<'a> {
&destination, &destination,
&copy_size &copy_size
)); ));
self.encoder_record_error(command_encoder_id, result); self.encoder_record_error(command_encoder_id, &result);
}, },
WebGPURequest::CreateBindGroup { WebGPURequest::CreateBindGroup {
device_id, device_id,
@ -982,7 +982,7 @@ impl<'a> WGPU<'a> {
} else { } else {
Err(String::from("Invalid ComputePass")) Err(String::from("Invalid ComputePass"))
}; };
self.encoder_record_error(command_encoder_id, result); self.encoder_record_error(command_encoder_id, &result);
}, },
WebGPURequest::RunRenderPass { WebGPURequest::RunRenderPass {
command_encoder_id, command_encoder_id,
@ -997,7 +997,7 @@ impl<'a> WGPU<'a> {
} else { } else {
Err(String::from("Invalid RenderPass")) Err(String::from("Invalid RenderPass"))
}; };
self.encoder_record_error(command_encoder_id, result); self.encoder_record_error(command_encoder_id, &result);
}, },
WebGPURequest::Submit { WebGPURequest::Submit {
queue_id, queue_id,
@ -1276,9 +1276,9 @@ impl<'a> WGPU<'a> {
fn encoder_record_error<U, T: std::fmt::Debug>( fn encoder_record_error<U, T: std::fmt::Debug>(
&self, &self,
encoder_id: id::CommandEncoderId, encoder_id: id::CommandEncoderId,
result: Result<U, T>, result: &Result<U, T>,
) { ) {
if let Err(e) = result { if let Err(ref e) = result {
self.error_command_encoders self.error_command_encoders
.borrow_mut() .borrow_mut()
.entry(encoder_id) .entry(encoder_id)