mirror of
https://github.com/penpot/penpot.git
synced 2026-01-25 06:41:27 -05:00
* 🔧 Fix lint script (rust) * 🔧 Temporarily add clippy rules to ignore so lint script passes * 💄 Fix clippy rule crate_in_macro_def * 💄 Fix clippy rule redundant-static-lifetimes * 💄 Fix clippy rule unnecessary_cast * 💄 Fix clippy rule nonminimal_bool * 💄 Fix clippy rule redundant_pattern_matching * 💄 Fix clippy rule assign_op_pattern * 💄 Fix clippy rule needless_lifetimes * 💄 Fix clippy rule for_kv_map * 💄 Fix clippy rule ptr_arg * 💄 Fix clippy rule match_like_matches_macro * 💄 Fix clippy rule macro_metavars_in_unsafe * 💄 Fix clippy rule map_clone * 💄 Fix clippy rule wrong_self_convention * 💄 Fix clippy rule vec_box * 💄 Fix clippy rule useless_format * 💄 Fix clippy rule unwrap_or_default * 💄 Fix clippy rule unused_unit * 💄 Fix clippy rule unnecessary_to_owned * 💄 Fix clippy rule too_many_arguments * 💄 Fix clippy rule slow_vector_initialization * 💄 Fix clippy rule single_match * 💄 Fix clippy rule redundant_field_names * 💄 Fix clippy rule rendudant_closure * 💄 Fix clippy rule needless_return * 💄 Fix clippy rule needless_range_loop * 💄 Fix clippy rule needless_borrows_for_generic_args * 💄 Fix clippy rule needless-borrow * 💄 Fix clippy rule missing_transmute_annotations * 💄 Fix clippy rule map_entry * 💄 Fix clippy rule manual_map * 💄 Fix clippy rule len_zero * 💄 Fix clippy rule from_over_into * 💄 Fix clippy rule field_reassign_with_default * 💄 Fix clippy rule enum_variant_names * 💄 Fix clippy rule derivable_impls * 💄 Fix clippy rule clone_on_copy * 💄 Fix clippy rule box_collection * 🔧 Make lint script also check test config target * 🔧 Remove cargo-watch as a lib dependency * 💄 Fix clippy rule for join_bounds * 🔧 Fix lint script return code --------- Co-authored-by: alonso.torres <alonso.torres@kaleidos.net>
169 lines
4.2 KiB
Rust
169 lines
4.2 KiB
Rust
#[allow(unused_imports)]
|
|
#[cfg(target_arch = "wasm32")]
|
|
use crate::get_now;
|
|
|
|
#[allow(dead_code)]
|
|
#[cfg(target_arch = "wasm32")]
|
|
pub fn get_time() -> i32 {
|
|
crate::get_now!() as i32
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
pub fn get_time() -> i32 {
|
|
let now = std::time::Instant::now();
|
|
now.elapsed().as_millis() as i32
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! mark {
|
|
($name:expr) => {
|
|
#[cfg(all(feature = "profile-macros", target_arch = "wasm32"))]
|
|
{
|
|
use $crate::run_script;
|
|
run_script!(format!("performance.mark('{}')", $name));
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! measure {
|
|
($name:expr) => {
|
|
#[cfg(all(feature = "profile-macros", target_arch = "wasm32"))]
|
|
{
|
|
use $crate::run_script;
|
|
run_script!(format!("performance.measure('{}')", $name));
|
|
}
|
|
};
|
|
($name:expr, $mark_begin:expr) => {
|
|
#[cfg(all(feature = "profile-macros", target_arch = "wasm32"))]
|
|
{
|
|
use $crate::run_script;
|
|
run_script!(format!(
|
|
"performance.measure('{}','{}')",
|
|
$name, $mark_begin
|
|
));
|
|
}
|
|
};
|
|
($name:expr, $mark_begin:expr, $mark_end:expr) => {
|
|
#[cfg(all(feature = "profile-macros", target_arch = "wasm32"))]
|
|
{
|
|
use $crate::run_script;
|
|
run_script!(format!(
|
|
"performance.measure('{}','{}','{}')",
|
|
$name, $mark_begin, $mark_end
|
|
));
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! begin_mark_name {
|
|
($name:expr) => {
|
|
format!("{}::begin", $name)
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! end_mark_name {
|
|
($name:expr) => {
|
|
format!("{}::end", $name)
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! measure_marks {
|
|
($name:expr) => {
|
|
#[cfg(all(feature = "profile-macros", target_arch = "wasm32"))]
|
|
{
|
|
use $crate::{begin_mark_name, end_mark_name, measure};
|
|
measure!($name, begin_mark_name!($name), end_mark_name!($name));
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! clear_marks {
|
|
() => {
|
|
use $crate::run_script;
|
|
run_script!("performance.clearMarks()");
|
|
};
|
|
($($name:expr),*) => {
|
|
format!("{}", [$(format!("performance.clearMarks('{}')", $name)),*].join("; "))
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! clear_measures {
|
|
() => {
|
|
use $crate::run_script;
|
|
run_script!("performance.clearMeasures()");
|
|
};
|
|
($($name:expr),*) => {
|
|
format!("{}", [$(format!("performance.clearMeasures('{}')", $name)),*].join("; "))
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! begin_measure {
|
|
($name:expr) => {
|
|
#[cfg(all(feature = "profile-macros", target_arch = "wasm32"))]
|
|
{
|
|
use $crate::{begin_mark_name, mark};
|
|
mark!(begin_mark_name!($name));
|
|
}
|
|
};
|
|
($name:expr, $clear_marks:expr) => {
|
|
#[cfg(all(feature = "profile-macros", target_arch = "wasm32"))]
|
|
{
|
|
use $crate::{begin_mark_name, clear_marks, end_mark_name, mark};
|
|
if $clear_marks {
|
|
clear_marks!(begin_mark_name!($name), end_mark_name($name));
|
|
}
|
|
mark!(begin_mark_name!($name));
|
|
}
|
|
};
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! end_measure {
|
|
($name:expr) => {
|
|
#[cfg(all(feature = "profile-macros", target_arch = "wasm32"))]
|
|
{
|
|
use $crate::{end_mark_name, mark, measure_marks};
|
|
mark!(end_mark_name!($name));
|
|
measure_marks!($name);
|
|
}
|
|
};
|
|
($name:expr, $clear_marks:expr) => {
|
|
#[cfg(all(feature = "profile-macros", target_arch = "wasm32"))]
|
|
{
|
|
use $crate::{begin_mark_name, clear_marks, end_mark_name, mark, measure_marks};
|
|
mark!(end_mark_name!($name));
|
|
measure_marks!($name);
|
|
if $clear_marks {
|
|
clear_marks!(begin_mark_name!($name), end_mark_name($name));
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
// We need to reexport the macro to make it public.
|
|
#[allow(unused_imports)]
|
|
pub use clear_marks;
|
|
|
|
#[allow(unused_imports)]
|
|
pub use clear_measures;
|
|
|
|
#[allow(unused_imports)]
|
|
pub use mark;
|
|
|
|
#[allow(unused_imports)]
|
|
pub use measure;
|
|
|
|
#[allow(unused_imports)]
|
|
pub use begin_measure;
|
|
|
|
#[allow(unused_imports)]
|
|
pub use end_measure;
|