struct Location size

deadalnix deadalnix at gmail.com
Thu May 11 23:08:31 UTC 2023


On Tuesday, 9 May 2023 at 00:32:33 UTC, Adam D Ruppe wrote:
> On Tuesday, 9 May 2023 at 00:24:44 UTC, Walter Bright wrote:
>>  6 bits for column - 1..64
>> 15 bits for line - 1..32768
>> 11 bits for file - 2047
>>
>> So, for great glory, can anyone come up with a clever scheme 
>> that uses only 32 bits?
>
> I wouldn't separate out column/line/file at all. Concatenate 
> all the files together in memory and store only an offset into 
> that gigantic array. If an error happens, then and only then go 
> back to extract the details by slicing the filename out of a 
> listing and rescanning it to determine line and column. (You'd 
> probably have an index that does a bit of both, like every new 
> file or every 5000 lines, add an entry to the lookup table. 
> Then when you do hit an error, you just need to scan from the 
> closest point forward instead of the whole thing.)
>
> If there's no errors, it uses little memory and is fast. If 
> there is an error, the rescanning time is not significant 
> anyway relative to the time to fix the error.

What if someone already implemented this. Wait...

https://github.com/snazzy-d/sdc/blob/master/src/source/manager.d
https://github.com/snazzy-d/sdc/blob/master/src/source/location.d



More information about the Digitalmars-d mailing list