-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simplify extccomp.nim json logic via jsonutils; fix #18084 #18100
simplify extccomp.nim json logic via jsonutils; fix #18084 #18100
Conversation
@@ -14,7 +14,7 @@ | |||
|
|||
import ropes, platform, condsyms, options, msgs, lineinfos, pathutils | |||
|
|||
import os, strutils, osproc, std/sha1, streams, sequtils, times, strtabs, json | |||
import std/[os, strutils, osproc, sha1, streams, sequtils, times, strtabs, json, jsonutils, sugar] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. If you want to improve this, give us a "jsonbuilder" module first. One that doesn't repeat json's mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Araq are you referring to timotheecour#745 (serialize/deserialize directly from string instead of from intermediate JsonNode) or to something else? If so, yes I agree timotheecour#745 is needed down the line for performance in similar cases but it would be a 1 liner change on top of this PR once that feature lands. If you're worried about performance I can make a benchmark but I don't see a reason why this PR would create any meaningful overhead.
the name jsonbuilder sounds like it'd be instead similar to the json.%*
operator (%* {"age":35, "pi":3.1415}
), but that's worse than what I'm doing as there's no spec/type-safety and serialization/deserialization would need more synchronization, unlike this PR with BuildCache
(which is analog to a protobuf proto)
this PR is a big code simplification as evidenced by the diff
Yes, that's my point.
I fail to see how.
I don't understand but jsonbuilder's API is not outlined anywhere so it's hard to communicate. |
once timotheecour#745 lands, the code in this PR can be changed as follows: conf.jsonBuildFile.string.writeFile(bcache.toJson.pretty)
...
bcache.fromJson(jsonFile.string.parseFile) => conf.jsonBuildFile.string.writeFile(bcache.toJsonStr(pretty = true))
...
bcache.fromJsonStr(jsonFile.string.readFile) # or directly from a stream to avoid `readFile`
in the meantime, there should be no performance penalty resulting from this PR even in absence of toJsonStr, fromJsonStr |
and indeed, here are timing results: before PRnim c compiler/nim 0.0006 after PRnim c compiler/nim 0.0006 => no performance drop as a result of this PR, not that there's anything surprising to that. |
…im-lang#18100) * simplify extccomp.nim json logic via jsonutils * fix nim-lang#18084 * simplify further * workaround for bootstrap that can be removed after updating csources_v1 >= 1.2
-d:nimBetterRun
(ornim r
) should recompile if set of config files change #18084the resulting code is much simpler, concise and maintainable (removes 100 LOC, and more after we'll remove the bootstrap workaround)