[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#852998: jessie-pu: package dropbear/2014.65-1



On Sun, 02 Apr 2017 at 19:46:16 +0100, Adam D. Barratt wrote:
> btw:
> 
> ++	for (i = 0; s[i] != '\0'; i++) {
> 
> is there a reason that isn't using strlen(s)?

A naive implementation with strlen() would be O(n**2), because the strlen()
would be recalculated on each loop iteration. It could be precomputed
and cached in a variable, but that would fully iterate the string twice;
it isn't clear to me how that would be better than the implementation in
the proposed patch.

    S


Reply to: