================
@@ -452,8 +452,7 @@ static void serializeArray(const Container &Records, Object 
&Obj,
     json::Value ItemVal = Object();
     auto &ItemObj = *ItemVal.getAsObject();
     SerializeInfo(Records[Index], ItemObj);
-    if (Index == Records.size() - 1)
-      ItemObj["End"] = true;
+    ItemObj["End"] = (Index == Records.size() - 1);
----------------
ilovepi wrote:

Does the `End` key always exist? If it does, was it initialized to `false`?

my concerns are that:

 1) if the key didn't always exist, it now may need handling, and all these 
objects are now larger for questionable value.
2) if the value was already initialized false, we're introducing unnecessary 
writes, which is wasteful. Most Index will not be the last one, so the branch 
predictor will be happier to just skip the instructions, and we hit memory less 
often.

What you wrote isn't wrong, I just don't want to increase object size or the 
number of writes if we don't really need to. Plus it feels ... inefficient to 
track if every entry in a list is the last one. I do concede that it may be 
hard to work around that in mustache.

https://github.com/llvm/llvm-project/pull/181417
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to