Skip to content

Commit

Permalink
Remove sorting in arguments function
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenszhu committed Jun 16, 2024
1 parent 43797eb commit e90b702
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,15 @@ end

@inline head(x::BasicSymbolic) = operation(x)

"""
$(TYPEDSIGNATURES)
Returns the arguments of `x` without sorting them.
This function must be defined if `iscall(x)` is `true`.
"""
function arguments(x::BasicSymbolic)
args = unsorted_arguments(x)
@compactified x::BasicSymbolic begin
Add => @goto ADD
Mul => @goto MUL
_ => return args
end
@label MUL
if !x.issorted[]
sort!(args, by=get_degrees)
x.issorted[] = true
end
return args

@label ADD
if !x.issorted[]
sort!(args, lt = monomial_lt, by=get_degrees)
x.issorted[] = true
end
return args
end

Expand Down

0 comments on commit e90b702

Please sign in to comment.