From c94d0be2edca23406f252eebb7af090bf4febcd3 Mon Sep 17 00:00:00 2001 From: Bulat Kurbanov Date: Wed, 21 Jun 2023 12:48:45 +0200 Subject: [PATCH] Optimize --- Cargo.lock | 3 +++ Cargo.toml | 2 +- src/bots/approved_bot/services/book_library/types.rs | 11 ++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0986cff..6d39eca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1822,6 +1822,9 @@ name = "smallvec" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +dependencies = [ + "serde", +] [[package]] name = "smawk" diff --git a/Cargo.toml b/Cargo.toml index e8ca4ed..5752c25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,4 +28,4 @@ sentry = "0.31.3" lazy_static = "1.4.0" moka = { version = "0.11.1", features = ["future"] } axum = "0.6.18" -smallvec = "1.10.0" +smallvec = { version = "1.10.0", features = ["serde"] } diff --git a/src/bots/approved_bot/services/book_library/types.rs b/src/bots/approved_bot/services/book_library/types.rs index 9b3bd05..aa7ff50 100644 --- a/src/bots/approved_bot/services/book_library/types.rs +++ b/src/bots/approved_bot/services/book_library/types.rs @@ -1,5 +1,6 @@ use core::fmt::Debug; use serde::Deserialize; +use smallvec::SmallVec; use super::formaters::{Format, FormatResult, FormatTitle}; @@ -192,7 +193,7 @@ pub struct Book { pub title: String, pub lang: String, // file_type: String, - pub available_types: Vec, + pub available_types: SmallVec<[String; 4]>, // uploaded: String, pub annotation_exists: bool, pub authors: Vec, @@ -211,7 +212,7 @@ pub struct SearchBook { pub title: String, pub lang: String, // file_type: String, - pub available_types: Vec, + pub available_types: SmallVec<[String; 4]>, // uploaded: String, pub annotation_exists: bool, pub authors: Vec, @@ -242,7 +243,7 @@ pub struct AuthorBook { pub title: String, pub lang: String, // file_type: String, - pub available_types: Vec, + pub available_types: SmallVec<[String; 4]>, // uploaded: String, pub annotation_exists: bool, pub translators: Vec, @@ -272,7 +273,7 @@ pub struct TranslatorBook { pub title: String, pub lang: String, // file_type: String, - pub available_types: Vec, + pub available_types: SmallVec<[String; 4]>, // uploaded: String, pub annotation_exists: bool, pub authors: Vec, @@ -303,7 +304,7 @@ pub struct SequenceBook { pub title: String, pub lang: String, // file_type: String, - pub available_types: Vec, + pub available_types: SmallVec<[String; 4]>, // uploaded: String, pub authors: Vec, pub translators: Vec,