mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
b21004b1d1
* https://github.com/denoland/deno_core/pull/752 * https://github.com/denoland/deno_core/pull/753 Did benchmarking on this and it's slightly faster (couple ms) or equal to in performance as main. Closes #23904
33 lines
627 B
Rust
33 lines
627 B
Rust
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
use deno_core::ModuleSpecifier;
|
|
|
|
pub enum CodeCacheType {
|
|
EsModule,
|
|
Script,
|
|
}
|
|
|
|
impl CodeCacheType {
|
|
pub fn as_str(&self) -> &str {
|
|
match self {
|
|
Self::EsModule => "esmodule",
|
|
Self::Script => "script",
|
|
}
|
|
}
|
|
}
|
|
|
|
pub trait CodeCache: Send + Sync {
|
|
fn get_sync(
|
|
&self,
|
|
specifier: &ModuleSpecifier,
|
|
code_cache_type: CodeCacheType,
|
|
source_hash: u64,
|
|
) -> Option<Vec<u8>>;
|
|
fn set_sync(
|
|
&self,
|
|
specifier: ModuleSpecifier,
|
|
code_cache_type: CodeCacheType,
|
|
source_hash: u64,
|
|
data: &[u8],
|
|
);
|
|
}
|