struct Location size

Walter Bright newshound2 at digitalmars.com
Wed May 10 03:08:12 UTC 2023


On 5/9/2023 2:35 AM, Dennis wrote:
> Line number and column number can be computed when needed, and can be 
> accelerated with a binary search in a list of line numbers sorted by file offset 
> (because of #line directives lines won't be monotonically increasing and need to 
> be stored in the list).
> 
> To handle multiple files, add the sum of all previous file sizes to the file 
> offset and have a mapping from the resulting 'global offset' to local file offset.

That should work, and avoids the need to keep the source file text around.



More information about the Digitalmars-d mailing list