nimja icon indicating copy to clipboard operation
nimja copied to clipboard

Const vars can be optimized into string blocks

Open enthus1ast opened this issue 2 years ago • 2 comments

Const variables can be optimized if they're touching a string block, saving an add call

enthus1ast avatar Mar 12 '22 03:03 enthus1ast

import macros
const foo = "foo baa"


macro dd(v: typed) =
  when v is static:
    echo "static!"
  else:
    echo "NON static!"
  if v.symKind == nskConst:
    echo "const!"
  else:
    echo "NON const"


dd(foo)

enthus1ast avatar Mar 12 '22 10:03 enthus1ast

It seems this is a hard issue: https://forum.nim-lang.org/t/9283

enthus1ast avatar Jul 07 '22 09:07 enthus1ast