@@ -502,7 +502,7 @@ function reorder_parameters(
502
502
end
503
503
end
504
504
505
- function reorder_parameters (ic:: IndexCache , ps; drop_missing = false )
505
+ function reorder_parameters (ic:: IndexCache , ps; drop_missing = false , flatten = true )
506
506
isempty (ps) && return ()
507
507
param_buf = if ic. tunable_buffer_size. length == 0
508
508
()
@@ -555,20 +555,37 @@ function reorder_parameters(ic::IndexCache, ps; drop_missing = false)
555
555
end
556
556
end
557
557
558
- result = broadcast .(
559
- unwrap, (
560
- param_buf... , initials_buf... , disc_buf... , const_buf... , nonnumeric_buf... ))
558
+ param_buf = broadcast .(unwrap, param_buf)
559
+ initials_buf = broadcast .(unwrap, initials_buf)
560
+ disc_buf = broadcast .(unwrap, disc_buf)
561
+ const_buf = broadcast .(unwrap, const_buf)
562
+ nonnumeric_buf = broadcast .(unwrap, nonnumeric_buf)
563
+
561
564
if drop_missing
562
- result = map (result) do buf
563
- filter (buf) do sym
564
- return ! isequal (sym, unwrap (variable (:DEF )))
565
- end
565
+ filterer = ! isequal (unwrap (variable (:DEF )))
566
+ param_buf = filter .(filterer, param_buf)
567
+ initials_buf = filter .(filterer, initials_buf)
568
+ disc_buf = filter .(filterer, disc_buf)
569
+ const_buf = filter .(filterer, const_buf)
570
+ nonnumeric_buf = filter .(filterer, nonnumeric_buf)
571
+ end
572
+
573
+ if flatten
574
+ result = (
575
+ param_buf... , initials_buf... , disc_buf... , const_buf... , nonnumeric_buf... )
576
+ if all (isempty, result)
577
+ return ()
566
578
end
579
+ return result
580
+ else
581
+ if isempty (param_buf)
582
+ param_buf = ((),)
583
+ end
584
+ if isempty (initials_buf)
585
+ initials_buf = ((),)
586
+ end
587
+ return (param_buf... , initials_buf... , disc_buf, const_buf, nonnumeric_buf)
567
588
end
568
- if all (isempty, result)
569
- return ()
570
- end
571
- return result
572
589
end
573
590
574
591
# Given a parameter index, find the index of the buffer it is in when
0 commit comments