Skip to content

Commit

Permalink
Merge pull request #2124 from scauligi/cleaner-quote
Browse files Browse the repository at this point in the history
Compile "quote" forms more compactly
  • Loading branch information
scauligi authored Jul 17, 2021
2 parents 35e20a2 + 0d8710c commit 3e28fe1
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions hy/core/result_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,10 @@ def render_quoted_form(compiler, form, level):
for x in form:
f_contents, splice = render_quoted_form(compiler, x, level)
if splice:
contents.append(Expression([
Symbol("list"),
Expression([Symbol("or"), f_contents, List()])]))
else:
contents.append(List([f_contents]))
if form:
# If there are arguments, they can be spliced
# so we build a sum...
body = [Expression([Symbol("+"), List()] + contents)]
else:
body = [List()]
f_contents = Expression([Symbol("unpack-iterable"),
Expression([Symbol("or"), f_contents, List()])])
contents.append(f_contents)
body = [List(contents)]

if isinstance(form, FString) and form.brackets is not None:
body.extend([Keyword("brackets"), form.brackets])
Expand All @@ -166,7 +159,7 @@ def render_quoted_form(compiler, form, level):
if form.brackets is not None:
body.extend([Keyword("brackets"), form.brackets])

ret = Expression([Symbol(name)] + body).replace(form)
ret = Expression([Symbol(name), *body]).replace(form)
return ret, False

# ------------------------------------------------
Expand Down

0 comments on commit 3e28fe1

Please sign in to comment.