From: Tobias C. R. <tc...@fr...> - 2008-12-27 16:23:09
|
"Tobias C. Rittweiler" <tc...@fr...> writes: > While pursuing to fix [Bug #310062], I encountered the following border > case I'd like to ask for your opinion: ... I've worked towards fixing this bug. To fix it properly, some refactoring is needed because currently there is no way to determine the kind of token (symbol, or number) under consideration. While refactoring I found out that the refactoring could nicely address an old FIXME. Currently, for each explicitly given package qualifier, a new string is constructed. This consing is avoided in the following branch of my git repository: http://repo.or.cz/w/sbcl/tcr.git?a=shortlog;h=refs/heads/bug-310062 I'll wait until this is merged before addressing Bug #310062 itself. -T. PS: A few notes on what I did in the patches: * Split the automaton that validates and differentiates tokens into its own function PARSE-TOKEN-FROM-STREAM. It's not called PARSE-TOKEN because I'll later add a function PARSE-TOKEN that can be used publically. * READ-TOKEN is now built on top of PARSE-TOKEN-FROM-STREAM. (The dispatch macro char for #: will later also be based on it.) * To fix the package qualifier consing I had to write a function FIND-PACKAGE* that works like FIND-SYMBOL*, i.e. that takes the whole read-buffer and a length argument. For this: - I renamed FIND-SYMBOL* and INTERN* to FIND-SYMBOL-FROM-SUBSTRING and INTERN-FROM-SUBSTRING. I also made these function take a START and an END, not just an END argument as before. - I implemented FIND-PACKAGE-FROM-SUBSTRING by using a customized hash-table which is used to map package names to packageoids. It is possible to use (LIST STRING START END) as key in that hash-table to mean the same as (SUBSEQ STRING START END) but without the consing. (Idea due to jsnell) - I made what was previously a macro WITH-SYMBOL an inlined function LOOKUP-SYMBOL, because I had to change this functionality to also take a START into account. Making it a function makes it more readable because previously the definition was drowning in commata. * For the customized hash-table, I also had to make DEFINE-HASH-TABLE-TEST be available during cold init. |