Closed kccqzy closed 7 years ago
Hi Joe!
I think this is a great idea. I've been pretty busy and haven't had a chance to look more closely into what this would take, but I've never been happy with that refcount allocation. Do you want to try replacing it with move constructors?
We could have an #ifdef
for the other stuff, or maybe a template parameter.
I'd support such an effort. :)
Thanks, Chad
Similar comments by @iboB in #28. I largely agree, and want to make it possible to use sajson without allocating. On that front, I just committed https://github.com/chadaustin/sajson/commit/39e271cb6ac20081bb7554848529142f54f70836 which only allocates the refcount if a copy of the input buffer must be made.
I'll probably write up a little doc or comment describing how to use sajson without allocating - it may require some sort of bounded AST region.
Hey @chadaustin. Sorry for not responding earlier. We are currently using a customized version of sajson with refcount and some other things completely removed. In particular, right now we have a static assert that checks std::is_trivially_destructible<sajson::document>::value
. Sorry that I didn't find the time to upstream this properly.
Thanks for the heads up! Do whatever you need to. :) One note: you may want to look at cherry-picking a few sajson commits - there were recently a couple important bug fixes. e.g. https://github.com/chadaustin/sajson/commit/0bd8a661421fc3e61262c283543689b0f8a88483
I'm going to mark this one as fixed by https://github.com/chadaustin/sajson/commit/39e271cb6ac20081bb7554848529142f54f70836 and continue the conversation in #28. Cheers!
Hi, I'm wondering if it is possible to officially support using sajson without any allocation at all. Currently, even if one uses
there will still be one allocation due to the use of
refcount
inmutable_string_view
. In some applications allocations should be avoided as much as possible, but in this case sajson will still calloperator new
with a size of asize_t
.I have a locally patched version of sajson that removes the use of
refcount
and changesmutable_string_view
to only take unowned strings:I'm thinking perhaps sajson could incorporate something similar officially? Perhaps using an
ifdef
, or some more templating? If this sounds cool, I can proceed to make a PR.