Skip to content

Commit 71382b0

Browse files
authored
Manage to remove the occurrence 5 "rebinding" by SnoopCompile (#1803)
1 parent 0e0bec9 commit 71382b0

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/common_options.jl

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,32 +1089,29 @@ function parse_B(d::Dict, cmd::String, opt_B__::String="", del::Bool=true)::Tupl
10891089

10901090
function titlices(d::Dict, arg, fun::Function)
10911091
# Helper function to deal with setting title & cousins while controling also Font & Offset
1092-
if (haskey(d, Symbol(fun)))
1093-
if isa(arg, StrSymb)
1094-
farg = arg
1095-
if (string(arg) == "auto")
1096-
farg = (fun == xlabel) ? CTRL.XYlabels[1] : (fun == ylabel) ? CTRL.XYlabels[2] : "auto"
1097-
(farg == "") && (farg = "auto") # Can't take the risk of letting go a "". GMT would (Ghrr) error
1098-
end
1099-
_tt, a_par = replace(str_with_blancs(farg), ' '=>'\x7f'), ""
1100-
_tt = replace(_tt, ">" => "\\076") # Avoid the shit of the shells taking precedence in parsing the > and < symbols
1101-
_tt = replace(_tt, "<" => "\\074")
1102-
else
1103-
_tt, a_par = fun(;arg...)
1092+
if isa(arg, StrSymb)
1093+
farg = arg
1094+
if (string(arg) == "auto")
1095+
farg = (fun == xlabel) ? CTRL.XYlabels[1] : (fun == ylabel) ? CTRL.XYlabels[2] : "auto"
1096+
(farg == "") && (farg = "auto") # Can't take the risk of letting go a "". GMT would (Ghrr) error
11041097
end
1105-
delete!(d, Symbol(fun));
1106-
_tt, a_par
1098+
_tt, a_par = replace(str_with_blancs(farg), ' '=>'\x7f'), ""
1099+
_tt = replace(_tt, ">" => "\\076") # Avoid the shit of the shells taking precedence in parsing the > and < symbols
1100+
_tt = replace(_tt, "<" => "\\074")
1101+
else
1102+
_tt, a_par = fun(; arg...)
11071103
end
1104+
_tt, a_par
11081105
end
11091106

11101107
# Let the :title and x|y_label be given on main kwarg list. Risky if used with NamedTuples way.
11111108
t::String = "" # Use the trick to replace blanks by Char(127) (invisible) and undo it in extra_parse
11121109
extra_par::String, tt::String, ep::String = "", "", ""
1113-
if (haskey(d, :title) && d[:title] != "") tt, extra_par = titlices(d, d[:title], title); t *= "+t" * tt end
1114-
if (haskey(d, :subtitle) && d[:subtitle] != "") tt, ep = titlices(d, d[:subtitle], subtitle);t *= "+s" * tt; extra_par *= ep end
1115-
if (haskey(d, :xlabel) && d[:xlabel] != "") tt, ep = titlices(d, d[:xlabel], xlabel); t *= " x+l" * tt; extra_par *= ep end
1116-
if (haskey(d, :ylabel) && d[:ylabel] != "") tt, ep = titlices(d, d[:ylabel], ylabel); t *= " y+l" * tt; extra_par *= ep end
1117-
if (haskey(d, :zlabel) && d[:zlabel] != "") tt, ep = titlices(d, d[:zlabel], zlabel); t *= " z+l" * tt; extra_par *= ep end
1110+
if ((v = find_in_dict(d, [:title])[1]) !== nothing && v !== "") tt, extra_par = titlices(d, v, title); t *= "+t" * tt end
1111+
if ((v = find_in_dict(d, [:subtitle])[1]) !== nothing && v !== "") tt, ep = titlices(d, v, subtitle); t *= "+s" * tt; extra_par *= ep end
1112+
if ((v = find_in_dict(d, [:xlabel])[1]) !== nothing && v !== "") tt, ep = titlices(d, v, xlabel); t *= " x+l" * tt; extra_par *= ep end
1113+
if ((v = find_in_dict(d, [:ylabel])[1]) !== nothing && v !== "") tt, ep = titlices(d, v, ylabel); t *= " y+l" * tt; extra_par *= ep end
1114+
if ((v = find_in_dict(d, [:zlabel])[1]) !== nothing && v !== "") tt, ep = titlices(d, v, zlabel); t *= " z+l" * tt; extra_par *= ep end
11181115
delete!(d, :title); delete!(d, :subtitle); delete!(d, :xlabel); delete!(d, :ylabel); delete!(d, :zlabel)# If == "" they were still there
11191116

11201117
if (t != "")

0 commit comments

Comments
 (0)