Skip to content

Commit

Permalink
feat: Remove lazy_static crate
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed Jun 4, 2024
1 parent 45ef565 commit a25e49f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ gitql-cli = "0.20.0"
gitql-ast = "0.18.0"
gitql-parser = "0.19.0"
gitql-engine = "0.20.0"
lazy_static = "1.4.0"
atty = "0.2.14"
clang-sys = "1.7.0"
13 changes: 7 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use gitql_std::aggregation::aggregation_function_signatures;
use gitql_std::aggregation::aggregation_functions;
use gitql_std::function::standard_function_signatures;
use gitql_std::function::standard_functions;
use schema::TABLES_FIELDS_NAMES;
use schema::TABLES_FIELDS_TYPES;
use schema::tables_fields_names;
use schema::tables_fields_types;

mod arguments;
mod data_provider;
Expand All @@ -45,9 +45,10 @@ fn main() {
reporter.report_diagnostic("", Diagnostic::error(error.as_str()));
return;
}

let schema = Schema {
tables_fields_names: TABLES_FIELDS_NAMES.to_owned(),
tables_fields_types: TABLES_FIELDS_TYPES.to_owned(),
tables_fields_names: tables_fields_names().to_owned(),
tables_fields_types: tables_fields_types().to_owned(),
};

let std_signatures = standard_function_signatures();
Expand Down Expand Up @@ -83,8 +84,8 @@ fn launch_clangql_repl(arguments: Arguments) {
}

let schema = Schema {
tables_fields_names: TABLES_FIELDS_NAMES.to_owned(),
tables_fields_types: TABLES_FIELDS_TYPES.to_owned(),
tables_fields_names: tables_fields_names().to_owned(),
tables_fields_types: tables_fields_types().to_owned(),
};

let std_signatures = standard_function_signatures();
Expand Down
16 changes: 9 additions & 7 deletions src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use gitql_core::types::DataType;
use lazy_static::lazy_static;
use std::collections::HashMap;
use std::sync::OnceLock;

lazy_static! {
pub static ref TABLES_FIELDS_TYPES: HashMap<&'static str, DataType> = {
pub fn tables_fields_types() -> &'static HashMap<&'static str, DataType> {
static HASHMAP: OnceLock<HashMap<&'static str, DataType>> = OnceLock::new();
HASHMAP.get_or_init(|| {
let mut map = HashMap::new();
map.insert("name", DataType::Text);
map.insert("type", DataType::Text);
Expand Down Expand Up @@ -40,11 +41,12 @@ lazy_static! {
map.insert("column", DataType::Integer);
map.insert("offset", DataType::Integer);
map
};
})
}

lazy_static! {
pub static ref TABLES_FIELDS_NAMES: HashMap<&'static str, Vec<&'static str>> = {
pub fn tables_fields_names() -> &'static HashMap<&'static str, Vec<&'static str>> {
static HASHMAP: OnceLock<HashMap<&'static str, Vec<&'static str>>> = OnceLock::new();
HASHMAP.get_or_init(|| {
let mut map = HashMap::new();
map.insert(
"classes",
Expand Down Expand Up @@ -107,5 +109,5 @@ lazy_static! {
],
);
map
};
})
}

0 comments on commit a25e49f

Please sign in to comment.