Skip to content

Consider adding a fast path for encode where indentation = 0 #37

@jakub-nlx

Description

@jakub-nlx

V8 recently landed a significant improvement to JSON serialization of "simple" objects (which is I think what we'll be 99% using). However, the gotcha being that you need to call JSON.stringify with only a single argument. Using the defaults of null, 0 doesn't trigger the fast path.

See https://news.ycombinator.com/item?id=44796648.

So in https://github.com/elm/json/blob/1.1.3/src/Elm/Kernel/Json.js#L415C24-L415C62, we'd need to do something like

var _Json_encode = F2(function(indentLevel, value)
{
       
	return indentLevel === 0 ? JSON.stringify(_Json_unwrap(value)) : JSON.stringify(_Json_unwrap(value), null, indentLevel) + '';
});

to opt into this optimization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions