Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
An illustration: the author's C++ solution takes a std::string by value, incurring an unintentional copy of the buffer. C++ makes it easy to make this mistake. C does not. But for the same reason C++ also makes it easy to use complicated objects and allocations when you need them for performance.
https://github.com/cesarvr/AOCRust/blob/590270ed268dcd4ff01b...
> I wonder if the javascript version is faster because it's less safe or because the JIT compiler identifies properly that unicode-awareness is useless and specializes the code.
Most JS VMs have several different string types internally. Looking at V8's source code (https://github.com/v8/v8/blob/master/src/builtins/builtins-s...), it looks like there's a very happy ASCII fast path that makes toLowerCase really fast on ASCII. Actually, it even looks as if it's processing the characters 8 bytes at a time (https://github.com/v8/v8/blob/master/src/strings/string-case...).
Related posts
- What does the code look like for built-in functions?
- What's happening with JavaScript Array References under the hood?
- FAMILIA PQ NAO TEM VAGA EM C E C++ NESSE MERCADO **********?????
- [AskJS] Do you have to be a natural talent to reach deep knowledge?
- [AskJS] Who first used the term "spread operator" re spread syntax ...?