Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the annotated join method and dispatch #51914

Merged
merged 1 commit into from
Feb 11, 2024

Commits on Feb 11, 2024

  1. Improve the annotated join method and dispatch

    With the initial implementation, join could work for AnnotatedStrings,
    however only when the eltype of the iterator or delim was itself a
    Annotated{String,Char}. This was better than nothing, but seems
    inconsistent in the face of mixed iterators.
    
    Furthermore, the implementation of an annotated join was far from
    optimised, relying on zipping and then calling annotatedstring(xs...).
    By contrast, the non-annotated implementation relies on printing to IO
    and even has manually defined alternative methods for optional arguments
    to minimise code generation.
    
    With the advent of AnnotatedIOBuffer and _isannotated, we can improve on
    both those aspects. The new AnnotatedIOBuffer type allows us to re-use
    the optimised join(::IO, ...) methods, and we can more reliably dispatch
    to them with _isannotated. Since this is a type-based decision, the
    Julia compiler is kind enough to work out which branch is taken at
    compile-time, making this zero-overhead in the unannotated case.
    tecosaur committed Feb 11, 2024
    Configuration menu
    Copy the full SHA
    024af3e View commit details
    Browse the repository at this point in the history