We noticed that ErrorStack() takes a considerable amount of cpu while computing the stack and the time is spent in SourceLine() method returning a New(err). This error is completely ignored in the String() method. The optimization is to give the builtin error instead of Error from an internal method which can be used by the String() method. To keep the backward compatibility, SourceLine() is modified to invoke the internal method sourceLine() and returning an Error.
We noticed that ErrorStack() takes a considerable amount of cpu while computing the stack and the time is spent in SourceLine() method returning a New(err). This error is completely ignored in the String() method. The optimization is to give the builtin error instead of Error from an internal method which can be used by the String() method. To keep the backward compatibility, SourceLine() is modified to invoke the internal method sourceLine() and returning an Error.