Commit 454e7e9
committed
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.1 parent 98542d7 commit 454e7e9
1 file changed
+9
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
373 | 361 | | |
374 | | - | |
| 362 | + | |
375 | 363 | | |
376 | 364 | | |
377 | 365 | | |
378 | | - | |
379 | | - | |
380 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
381 | 369 | | |
382 | 370 | | |
383 | 371 | | |
| |||
0 commit comments