Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uncurry: avoid intermediate lists, remove ParamTransform ADT:
The erase method in the Uncurry file was creating several lists: - The input lists of lists `vparamss` and `dd.symbol.info.paramss` were flattened, into a List that was only used in a single loop run, with the `map2` function, to create... - ... `paramTransforms`, a list of objects of the "ParamTransform" ADT, which has the subclasses "Identity" and "Packed". - The `allParams` was mapped from the previous one, by getting only the `param`. This is returned in first element of response tuple. - A list of pairs that is obtained by a `collect` - The lists `packedParams` and `tempVals`, that are obtained by unzipping the collected list above. - The `packedParams` was only use to map it into the list of symbols, which is used for a symbol substitution. We rewrite this code to avoid generating so many lists: - We replace the list flattening with flattened iterators. - We use mutable ListBuffers, and use a single pass over those iterators, so in each iteration we add an element to three lists. - We generate three lists: the `allParams`, the symbols of the `packedParams` (without the packed params), and the tempVals. We cannot remove the map of tempVals to symbols, because tempVals can be needed for the output. However... - If we detect that the tree is the Empty tree, we avoid inserting the `packedParams` symbols, or the tempVals. - We remove the `ParamTransform` ADT. Also, since the `Identity` and `Packed` classes were just a carrier of its fields from one part of the `erase` method to another part of it, we can remove them and directly add the info in their fields to the lists were we need to.
- Loading branch information