From 372797636846aed92ccd19967a17855f6b89f6fa Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Mon, 10 May 2021 22:37:13 +0900 Subject: [PATCH] virtio: video: decoder: replace ContextMap's new() method by Default implementation This is more idiomatic for constructors that take no arguments, and spares us one compiler warning if decoding support is enabled without any backend (in which case nobody creates ContextMaps). BUG=b:169295147 TEST=cargo build --features="video-decoder" Change-Id: I01b909eac6d443e43617f6e8cb91c6254dea5cc5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2891136 Tested-by: kokoro Commit-Queue: Alexandre Courbot Reviewed-by: Keiichi Watanabe Reviewed-by: Chih-Yu Huang --- devices/src/virtio/video/decoder/mod.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/devices/src/virtio/video/decoder/mod.rs b/devices/src/virtio/video/decoder/mod.rs index 4ee9ddfe17..2e98263673 100644 --- a/devices/src/virtio/video/decoder/mod.rs +++ b/devices/src/virtio/video/decoder/mod.rs @@ -356,12 +356,6 @@ struct ContextMap { } impl ContextMap { - fn new() -> Self { - ContextMap { - map: Default::default(), - } - } - fn insert(&mut self, ctx: Context) -> VideoResult<()> { match self.map.entry(ctx.stream_id) { Entry::Vacant(e) => { @@ -390,6 +384,14 @@ impl ContextMap { } } +impl Default for ContextMap { + fn default() -> Self { + Self { + map: Default::default(), + } + } +} + /// Represents information of a decoder backed by a `DecoderBackend`. pub struct Decoder { decoder: D, @@ -1097,7 +1099,7 @@ impl Decoder { Ok(Decoder { decoder: vda, capability, - contexts: ContextMap::new(), + contexts: Default::default(), }) } }