Skip to content

Commit

Permalink
Bound the length of nls completions (#2073)
Browse files Browse the repository at this point in the history
* Limit the sizes of contracts in completion details

* Improve the nls benches a little

* Use guards

* Fix bench build

* Generics cleanups, scope cleanups
  • Loading branch information
jneem authored Oct 22, 2024
1 parent 73d71eb commit 6a0d041
Show file tree
Hide file tree
Showing 7 changed files with 315 additions and 232 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions core/benches/arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
use criterion::criterion_main;
use nickel_lang_core::term::{array::ArrayAttrs, Number, RichTerm, Term};
use nickel_lang_utils::{bench::criterion_config, bench::EvalMode, ncl_bench_group};
use pretty::{BoxAllocator, DocBuilder, Pretty};
use pretty::{DocBuilder, Pretty};

/// Generates a pseaudo-random Nickel array as a string.
#[cfg(not(feature = "benchmark-ci"))]
fn ncl_random_array(len: usize) -> String {
use nickel_lang_core::pretty::Allocator;

let m = 2_u64.pow(32);
let a = 1664525;
let c = 1013904223;
Expand All @@ -24,7 +26,8 @@ fn ncl_random_array(len: usize) -> String {
numbers.into_iter().collect(),
ArrayAttrs::default(),
));
let doc: DocBuilder<_, ()> = xs.pretty(&BoxAllocator);
let alloc = Allocator::default();
let doc: DocBuilder<_, ()> = xs.pretty(&alloc);
let mut out = Vec::new();
doc.render(80, &mut out).unwrap();
String::from_utf8(out).unwrap()
Expand Down
Loading

0 comments on commit 6a0d041

Please sign in to comment.