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 <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
This commit is contained in:
Alexandre Courbot 2021-05-10 22:37:13 +09:00 committed by Commit Bot
parent b6ae6517ae
commit 3727976368

View file

@ -356,12 +356,6 @@ struct ContextMap<S: DecoderSession> {
}
impl<S: DecoderSession> ContextMap<S> {
fn new() -> Self {
ContextMap {
map: Default::default(),
}
}
fn insert(&mut self, ctx: Context<S>) -> VideoResult<()> {
match self.map.entry(ctx.stream_id) {
Entry::Vacant(e) => {
@ -390,6 +384,14 @@ impl<S: DecoderSession> ContextMap<S> {
}
}
impl<S: DecoderSession> Default for ContextMap<S> {
fn default() -> Self {
Self {
map: Default::default(),
}
}
}
/// Represents information of a decoder backed by a `DecoderBackend`.
pub struct Decoder<D: DecoderBackend> {
decoder: D,
@ -1097,7 +1099,7 @@ impl Decoder<libvda::decode::VdaInstance> {
Ok(Decoder {
decoder: vda,
capability,
contexts: ContextMap::new(),
contexts: Default::default(),
})
}
}