Skip to content

Commit 68a5331

Browse files
authored
Remove lazy static dependency (#448)
1 parent 522529e commit 68a5331

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ cc = "1.0"
3939
[dev-dependencies]
4040
criterion = "0.5.1"
4141
proptest = "1.5.0"
42-
lazy_static = "1.4.0"
4342

4443
[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
4544
jemallocator = "0.5.0"

examples/check_real_memory.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Under linux, we choose to use smem, which can monitor memory changes more accurately
33

44
use ckb_vm::{run_with_memory, Bytes, FlatMemory, SparseMemory};
5-
use lazy_static::lazy_static;
65
use std::process::{id, Command};
76

87
#[cfg(has_asm)]
@@ -17,11 +16,8 @@ use ckb_vm::{
1716
#[cfg(has_asm)]
1817
use std::thread;
1918

20-
lazy_static! {
21-
pub static ref BIN_PATH_BUFFER: Bytes =
22-
Bytes::from(&include_bytes!("../tests/programs/alloc_many")[..]);
23-
pub static ref BIN_NAME: String = format!("alloc_many");
24-
}
19+
static BIN_PATH_BUFFER: &'static [u8] = include_bytes!("../tests/programs/alloc_many");
20+
static BIN_NAME: &str = "alloc_many";
2521

2622
#[cfg(not(target_os = "windows"))]
2723
#[global_allocator]
@@ -128,8 +124,8 @@ fn check_interpreter(memory_size: usize) -> Result<(), ()> {
128124
println!("Base memory: {}", get_current_memory());
129125
for _ in 0..G_CHECK_LOOP {
130126
let result = run_with_memory::<u64, SparseMemory<u64>>(
131-
&BIN_PATH_BUFFER,
132-
&vec![BIN_NAME.clone().into()],
127+
&Bytes::from(BIN_PATH_BUFFER),
128+
&vec![Bytes::from(BIN_NAME)],
133129
SparseMemory::new_with_memory(memory_size),
134130
);
135131
assert!(result.is_ok());
@@ -148,8 +144,8 @@ fn check_falt(memory_size: usize) -> Result<(), ()> {
148144
println!("Base memory: {}", get_current_memory());
149145
for _ in 0..G_CHECK_LOOP {
150146
let result = run_with_memory::<u64, FlatMemory<u64>>(
151-
&BIN_PATH_BUFFER,
152-
&vec![BIN_NAME.clone().into()],
147+
&Bytes::from(BIN_PATH_BUFFER),
148+
&vec![Bytes::from(BIN_NAME)],
153149
FlatMemory::new_with_memory(memory_size),
154150
);
155151
assert!(result.is_ok());
@@ -172,7 +168,7 @@ fn check_asm(memory_size: usize) -> Result<(), ()> {
172168
let core = DefaultMachineBuilder::new(asm_core).build();
173169
let mut machine = AsmMachine::new(core);
174170
machine
175-
.load_program(&BIN_PATH_BUFFER, &vec![BIN_NAME.clone().into()])
171+
.load_program(&Bytes::from(BIN_PATH_BUFFER), &vec![Bytes::from(BIN_NAME)])
176172
.unwrap();
177173
let result = machine.run();
178174
assert!(result.is_ok());
@@ -196,7 +192,7 @@ fn check_asm_in_thread(memory_size: usize) -> Result<(), ()> {
196192
let core = DefaultMachineBuilder::new(asm_core).build();
197193
let mut machine = AsmMachine::new(core);
198194
machine
199-
.load_program(&BIN_PATH_BUFFER, &vec![BIN_NAME.clone().into()])
195+
.load_program(&Bytes::from(BIN_PATH_BUFFER), &vec![Bytes::from(BIN_NAME)])
200196
.unwrap();
201197
let thread_join_handle = thread::spawn(move || {
202198
let result = machine.run();

0 commit comments

Comments
 (0)