4 ms·
That’s explained at the end of the post: in the real code, that’s the most efficient place to calculate it, and it was passed back out as well.
by robin_reala 3y ago
That’s explained at the end of the post: in the real code, that’s the most efficient place to calculate it, and it was passed back out as well.
- __float 3y agoThat was some key context lost in the simplification of the original code[1] for this blog post, though. The blog post's code returns the temperature (throwing away the next line), whereas the original adds it to a map and returns the next line. [1] https://github.com/gunnarmorling/1brc/blob/dfec2cdbe6a0334cff054f333ec4b4d9e4d775cf/src/main/java/dev/morling/onebrc/CalculateAverage_merykitty.java#L165-L195 https://github.com/gunnarmorling/1brc/blob/dfec2cdbe6a0334cf...
- haxen 3y agoThere are many variations of the original code used in different solutions. Many of them return the temperature like the variant used in the post, but they split out the part that finds the decimal dot into a separate function. Then you can reuse that twice: to finish parsing the temperature, and to advance the cursor to the next row.