Re: XML and XSLT Praise
"Franck Arnaud" <[email protected]> Fri, 30 May 2008 14:06:05 +0100
| Newsgroups | gmane.comp.lang.eiffel.gobo.general |
|---|---|
| Message-ID | <[email protected]> |
> Franck> there's considerable scope for improvememt there though,
> Franck> this functionality could be implemented in a small
> Franck> fraction of the existing code (the geuc generated classes
> Franck> could be much smaller).
>
> How?
For example many arrays are sparse and could have the most common value
set with a routine call and then the non-common value set individually,
so if a 256 item array has say 3 values that differ from the default,
that reduces 256 lines of generated code to 4. Or maybe use Void for
default values (a if /= Void test might be faster than a memory
reference nowadays).
For other highly repetitive things the code can be similarly shortened
(e.g. add and use a array_put_n_times (value, start_index, n_times)
function).
The new_triple business could be initialised from an array (arity,
position, item1...itemarity)*, e.g.
initialize_from_array (a_result: ARRAY [DS_ARRAYED_LIST [INTEGER]];
a_init_array: ARRAY [INTEGER]) is
....
from i := 1 until i > a_array.count loop
l_arity := a_array.item (i)
l_position := a_array.item (i + 1)
i := i + 2
inspect l_arity
when 1 then
a_result.put (new_singleton (a_array.item (i)), l_position)
when 2 then
a_result.put (new_pair (a_array.item (i), a_array.item (i+1)),
l_position)
when 3 then ...
when 4 then ...
end
i := i + l_arity
end
....
So instead of code you get that function and constant integer arrays.
Perhaps such a function could deal with building the segments too
(having one big array instead of one per segment for the initialization)
though not sure if that's productive or not.
At the extreme the whole normalization data could be stored into one big
constant string with some code that reads it and turns it into the
relevant data structures the first time they're used. Arguably there
might be some compromise here between code size and runtime
initialization costs, and I'm not saying it's necessary to go that far.