Skip to content

VirtuallyRotatedTextWithTerminator: avoid building RotatedTextWithTerminator #51

@antonioaversa

Description

@antonioaversa

Improvement: avoid building RotatedTextWithTerminator and have VirtuallyRotatedTextWithTerminator access directly to the underlying TextWithTerminator.

Currently the construction of a VirtuallyRotatedTextWithTerminator instance requires wrapping the underlying TextWithTerminator into a RotatedTextWithTerminator: c.p. the following excerpt from

new(new(text, text.Terminator, false), rotation);

    public static VirtuallyRotatedTextWithTerminator ToVirtuallyRotated(this TextWithTerminator text, int rotation) =>
        new(new(text, text.Terminator, false), rotation);

Why: on large input (strings of hundreds of MB), a RotatedTextWithTerminator instance has to be built for each "virtual rotation" of the input, i.e. as many instances of this object are created as chars in the input. This leads to a high memory usage, and possibly to OutOfMemoryException.

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementImprovement of an existing feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions