We're currently working with the length of the string itself, which is
the number of bytes. That's wrong in these functions which operate at
the level of characters. When applied to a string with a multibyte
character they can return the wrong result. For example, evaluating
`std.rstripChars('• foo\n', '\n')` results in `"• f"`.
What we need to do instead is get the number of runes, and remove one
rune at a time.
This commit fixes a regression in std.manifestJsonEx that caused the
standard library function to error when the given value was an array.
Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
Fixes multiple issues with stack traces leading to missing
stack trace lines. Also, we no longer put builtin context
on the line which *calls* the builtin as if it was a part
of the builtin itself.
Code for stack trace handling was centralized. We no longer
need traceElement argument in ~every function. Now the stack
trace state is kept solely in the interpreter.
Desugar the locals in object comprehensions
"traditionally" instead of handling them manually.
Object comprehensions allow the locals to depend
on the index variable which means that they are separate
for each field. It doesn't make sense to treat them as
a property of the whole object.
Fixes#358.
❯ make benchmark FILTER=Builtin_manifestJsonEx
go build ./cmd/jsonnet
./benchmark.sh Builtin_manifestJsonEx
Running Before Test... (10s)
Running After Test... (10s)
benchmark old ns/op new ns/op delta
Benchmark_Builtin_manifestJsonEx-16 22656394 7502016 -66.89%
feat: improve std.base64Decode performance 97%+
Provides a Go-native implementation of std.base64Decode and std.base64DecodeBytes
benchmark old ns/op new ns/op delta
Benchmark_Builtin_base64Decode-16 10946388307 25004135 -99.77%
Benchmark_Builtin_base64DecodeBytes-16 6420742757 181513016 -97.17%
related to #111
Implements std.reverse in native Go, improving performance
benchmark old ns/op new ns/op delta
Benchmark_Builtin_reverse-16 869191619 231309458 -73.39%
part of #111
This pulls in the implementation of substr into native Go instead of interpretted Jsonnet.
benchmark old ns/op new ns/op delta
Benchmark_Builtin_substr-16 97121527 15115905 -84.44%
part of #111
When adding long strings, don't copy them immediately. Instead
build long strings only when their contents are requested.
This allows to build a long string from parts, using a regular
operator+ in linear time. This lets users to worry much less
about using std.join etc.
If indexing the string is mixed with building it using operator+
the behavior can still be quadratic. We may want to address it in
a later change.