2016-01-24 19:53 GMT+03:00 Bram Moolenaar <[email protected]>:
>
> Nikolai Pavlov wrote:
>
> > Consider the following code:
> >
> > vim -u NONE --cmd 'let l=[]' --cmd 'call map(range(1024*1024),
> "extend(g:, {\"l\": [g:l]})")' --cmd 'echo jsonencode(l)'
> >
> > This crashes with stack full of json_encode_item() calls.
> >
> > One may be interested in code from neovim/neovim#3365 because it is
> > not using recursion for dumping values.
>
> The current implementation wasn't really made for large JSON files.
> But if someone makes a patch it might get included.
> Besides the recursiveness, using the growarray probably also is quite
> inefficient. list_join_inner() has a better solution, but it takes
> quite a bit of code.
If one takes implementation from Neovim it is not a problem to make it
first compute length and then dump. The problem is that json_encode_item
should have at least stack overflow protection common for other recursive
calls: I mean, a counter.
>
>
> --
> hundred-and-one symptoms of being an internet addict:
> 36. You miss more than five meals a week downloading the latest games from
> Apogee.
>
> /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
> /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\ an exciting new programming language -- http://www.Zimbu.org ///
> \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/vim/vim/issues/588#issuecomment-174315735>.
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.