google / cel-go

Fast, portable, non-Turing complete expression evaluation with gradual typing (Go)
https://cel.dev
Apache License 2.0
2.31k stars 225 forks source link

Avoid iterating over the source multiple times #936

Closed jcking closed 7 months ago

jcking commented 7 months ago

When creating a source, we iterate once to calculate line offsets and then iterate a second time to create the underlying buffer. This change moves the logic to calculate line offsets into the buffer creation. This avoids iterating the source twice and counting code points.