3 ms·
However, you should not actually do that, because changing s reallocates it, so you get O(n^2) runtime Should be like, getinteger(const s : string; var startPo
by benibela 6y ago
However, you should not actually do that, because changing s reallocates it, so you get O(n^2) runtime
Should be like, getinteger(const s : string; var startPos: sizeint):integer;
Pascal always has the best possible ideas, and then fucks up the implementation.
- mikewarot 6y ago> However, you should not actually do that, because changing s reallocates it, so you get O(n^2) runtime Confirmed by experiment. Parsing 1,2,...1000 string 1000 times 0.355 seconds Parsing 1,2,....10000 string 1000 times 42.835 seconds A given string might have 1-10 parameters in it, so the actual execution time isn't going to be that bad. I always think in terms of those 10 Mhz 286s, and how much faster it is these days. ;-) Obviously, if I were reading Gigabytes of text, I might optimize a bit.