diff --git a/Cargo.lock b/Cargo.lock index e55c267..dc0e889 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -787,15 +787,6 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "itertools" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.13.0" @@ -855,7 +846,7 @@ dependencies = [ "futures", "hdrhistogram", "hytra", - "itertools 0.13.0", + "itertools", "jemallocator", "lazy_static", "metrohash", @@ -1809,7 +1800,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scylla" version = "0.13.0" -source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#ea914d446d2172d3470f1e4de5fd87d55962b51a" +source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#f3eb38947ef22581ff7cc368c3f8dff3ed1919a6" dependencies = [ "arc-swap", "async-trait", @@ -1820,7 +1811,7 @@ dependencies = [ "futures", "hashbrown", "histogram", - "itertools 0.11.0", + "itertools", "lazy_static", "lz4_flex", "openssl", @@ -1841,7 +1832,7 @@ dependencies = [ [[package]] name = "scylla-cql" version = "0.2.0" -source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#ea914d446d2172d3470f1e4de5fd87d55962b51a" +source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#f3eb38947ef22581ff7cc368c3f8dff3ed1919a6" dependencies = [ "async-trait", "byteorder", @@ -1857,7 +1848,7 @@ dependencies = [ [[package]] name = "scylla-macros" version = "0.5.0" -source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#ea914d446d2172d3470f1e4de5fd87d55962b51a" +source = "git+https://github.com/pkolaczk/scylla-rust-driver.git?branch=vector#f3eb38947ef22581ff7cc368c3f8dff3ed1919a6" dependencies = [ "darling", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 21af9be..247db0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ panic = "abort" [profile.dev-opt] inherits = "dev" -opt-level = 2 +opt-level = 3 [package.metadata.deb] name = "latte" diff --git a/src/scripting/functions.rs b/src/scripting/functions.rs index 668a024..7efd060 100644 --- a/src/scripting/functions.rs +++ b/src/scripting/functions.rs @@ -104,19 +104,25 @@ pub fn uniform(i: i64, min: f64, max: f64) -> VmResult { } #[rune::function] -pub fn uniform_vec(i: i64, len: usize, min: f64, max: f64) -> VmResult> { +pub fn uniform_vec(i: i64, len: usize, min: f64, max: f64) -> VmResult { let mut rng = SmallRng::seed_from_u64(i as u64); - let vec: Vec = (0..len).map(|_| rng.gen_range(min..max)).collect(); - VmResult::Ok(vec) + let mut vec = vm_try!(rune::alloc::Vec::try_with_capacity(len)); + for _ in 0..len { + vm_try!(vec.try_push(Value::Float(rng.gen_range(min..max)))); + } + Value::vec(vec) } #[rune::function] -pub fn normal_vec(i: i64, len: usize, mean: f64, std_dev: f64) -> VmResult> { +pub fn normal_vec(i: i64, len: usize, mean: f64, std_dev: f64) -> VmResult { let mut rng = SmallRng::seed_from_u64(i as u64); let distribution = vm_try!(Normal::new(mean, std_dev).map_err(|e| VmError::panic(format!("{e}")))); - let vec: Vec = (0..len).map(|_| rng.sample(distribution)).collect(); - VmResult::Ok(vec) + let mut vec = vm_try!(rune::alloc::Vec::try_with_capacity(len)); + for _ in 0..len { + vm_try!(vec.try_push(Value::Float(rng.sample(distribution)))); + } + Value::vec(vec) } /// Generates random blob of data of given length.