mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-03 10:24:44 +00:00
Replaced deprecated repeatStr() with repeat().
This commit is contained in:
@@ -949,7 +949,7 @@ proc genEcho(p: BProc, n: PNode) =
|
||||
initLocExpr(p, n.sons[i], a)
|
||||
appf(args, ", $1? ($1)->data:\"nil\"", [rdLoc(a)])
|
||||
linefmt(p, cpsStmts, "printf($1$2);$n",
|
||||
makeCString(repeatStr(n.len, "%s") & tnl), args)
|
||||
makeCString(repeat("%s", n.len) & tnl), args)
|
||||
|
||||
proc gcUsage(n: PNode) =
|
||||
if gSelectedGC == gcNone: message(n.info, warnGcMem, n.renderTree)
|
||||
|
||||
@@ -461,9 +461,9 @@ proc indentToLevel(level: var int, newLevel: int): string =
|
||||
if level == newLevel:
|
||||
return
|
||||
if newLevel > level:
|
||||
result = repeatStr(newLevel - level, "<ul>")
|
||||
result = repeat("<ul>", newLevel - level)
|
||||
else:
|
||||
result = repeatStr(level - newLevel, "</ul>")
|
||||
result = repeat("</ul>", level - newLevel)
|
||||
level = newLevel
|
||||
|
||||
proc generateDocumentationTOC(entries: seq[TIndexEntry]): string =
|
||||
|
||||
@@ -144,7 +144,7 @@ when isMainModule:
|
||||
discard """block:
|
||||
var
|
||||
TestFile: FileChallengePair
|
||||
contents = repeatStr(2, "abcdefghijklmnopqrstuvwxyz")
|
||||
contents = repeat("abcdefghijklmnopqrstuvwxyz", 2)
|
||||
testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32)
|
||||
testFile.file = checksumStr(contents)
|
||||
myAssets.add testFile"""
|
||||
|
||||
@@ -27,9 +27,9 @@ when isMainModule:
|
||||
var res = t.map(proc(z: int): int = result = z * 10)
|
||||
dumpSeq res
|
||||
|
||||
from strutils import toHex, repeatStr
|
||||
from strutils import toHex
|
||||
var foocakes = t.map(proc(z: int): string =
|
||||
result = toHex((z * 23).biggestInt, 4))
|
||||
result = toHex((z * 23).BiggestInt, 4))
|
||||
dumpSeq foocakes
|
||||
|
||||
t.mapInPlace(proc(z: int): int = result = z * 30)
|
||||
|
||||
@@ -24,17 +24,17 @@ when isMainModule:
|
||||
import strutils
|
||||
var r = compress("Hello")
|
||||
echo repr(r)
|
||||
var l = "Hello".len
|
||||
var rr = uncompress(r, l)
|
||||
var ln = "Hello".len
|
||||
var rr = uncompress(r, ln)
|
||||
echo repr(rr)
|
||||
assert rr == "Hello"
|
||||
|
||||
proc `*`(a: string; b: int): string {.inline.} = result = repeatStr(b, a)
|
||||
proc `*`(a: string; b: int): string {.inline.} = result = repeat(a, b)
|
||||
var s = "yo dude sup bruh homie" * 50
|
||||
r = compress(s)
|
||||
echo s.len, " -> ", r.len
|
||||
|
||||
l = s.len
|
||||
rr = uncompress(r, l)
|
||||
ln = s.len
|
||||
rr = uncompress(r, ln)
|
||||
echo r.len, " -> ", rr.len
|
||||
assert rr == s
|
||||
@@ -174,7 +174,7 @@ when isMainModule:
|
||||
block:
|
||||
var
|
||||
TestFile: FileChallengePair
|
||||
contents = repeatStr(2, "abcdefghijklmnopqrstuvwxyz")
|
||||
contents = repeat("abcdefghijklmnopqrstuvwxyz", 2)
|
||||
testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32)
|
||||
testFile.file = checksumStr(contents)
|
||||
myAssets.add testFile
|
||||
|
||||
@@ -99,8 +99,8 @@ macro updated(e: expr): expr {.immediate.} =
|
||||
proc updatedDate(year, month, day: string): string =
|
||||
## wrapper around the update macro with easy input.
|
||||
result = updated("$1-$2-$3T00:00:00Z" % [year,
|
||||
repeatStr(2 - len(month), "0") & month,
|
||||
repeatStr(2 - len(day), "0") & day])
|
||||
repeat("0", 2 - len(month)) & month,
|
||||
repeat("0", 2 - len(day)) & day])
|
||||
|
||||
macro entry(e: expr): expr {.immediate.} =
|
||||
## generates the rss xml ``entry`` element.
|
||||
|
||||
Reference in New Issue
Block a user