Replace lineno function with a smaller and faster implementation