[riot-notifications] [RIOT-OS/RIOT] sys/phydat: added phydat to JSON converter (#7271)

Hauke Petersen notifications at github.com
Wed May 20 15:47:33 CEST 2020


@haukepetersen commented on this pull request.



> +            }
+            else {
+                pos += (data->val[i]) ? 4 : 5;  /* true: 4, false: 5 */
+            }
+        }
+        pos += strlen(phydat_unit_to_str_verbose(data->unit));
+    }
+    else {
+        memcpy(buf, "{\"d\":", 5);
+        pos += 5;
+        /* write data */
+        if (dim > 1) {
+            buf[pos++] = '[';
+        }
+        for (size_t i = 0; i < dim; i++) {
+            if (data->unit != UNIT_BOOL) {

not quite, as the toolchain can not judge the probability here... The key impact is the CPU: on anything desktop-ish it does indeed not matter as the branch prediction in the CPU will make all paths equally fast by caching them. Also some RIOT platforms (aka m3, m4) do have some form of branch prediction. But the less advanced platforms (avr8, m0) do not support such a thing and hence manual ordering of conditions has an impact, though arguably not a significant one...

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/7271#discussion_r428024456
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200520/b7abe0dd/attachment.htm>


More information about the notifications mailing list