summary refs log tree commit diff stats
path: root/lib/std/private/miscdollars.nim
blob: 840fedf54e626921d8e103a3c86068de1d56d398 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from std/private/digitsutils import addInt

template toLocation*(result: var string, file: string | cstring, line: int, col: int) =
  ## avoids spurious allocations
  # Hopefully this can be re-used everywhere so that if a user needs to customize,
  # it can be done in a single place.
  result.add file
  if line > 0:
    result.add "("
    addInt(result, line)
    if col > 0:
      result.add ", "
      addInt(result, col)
    result.add ")"