This is the O (n) algorithm. The time taken to execute will increase more or less linearly with the length of the string you are converting (although if you are converting millions of very short lines, the additional overhead of function calls will be added to this).
In almost all situations this will not be a bottleneck. You could probably encode very large strings of several tens of megabytes in a short amount of time. However, I have no actual control data.
source
share