distinction between re.replace and re.replacef; speed improvements for re module
This commit is contained in:
parent
e424e13bd9
commit
3005955d20
23 changed files with 206 additions and 171 deletions
|
|
@ -7,7 +7,7 @@
|
|||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
# implements some little helper passes
|
||||
## implements some little helper passes
|
||||
|
||||
import
|
||||
strutils, ast, astalgo, passes, msgs, options
|
||||
|
|
@ -20,7 +20,11 @@ proc verboseOpen(s: PSym, filename: string): PPassContext =
|
|||
proc verboseProcess(context: PPassContext, n: PNode): PNode =
|
||||
result = n
|
||||
if context != nil: InternalError("logpass: context is not nil")
|
||||
if gVerbosity == 3: Message(n.info, hintProcessing, $ast.gid)
|
||||
if gVerbosity == 3:
|
||||
# system.nim deactivates all hints, for verbosity:3 we want the processing
|
||||
# messages nonetheless, so we activate them again unconditionally:
|
||||
incl(msgs.gNotes, hintProcessing)
|
||||
Message(n.info, hintProcessing, $ast.gid)
|
||||
|
||||
proc verbosePass*(): TPass =
|
||||
initPass(result)
|
||||
|
|
@ -28,7 +32,6 @@ proc verbosePass*(): TPass =
|
|||
result.process = verboseProcess
|
||||
|
||||
proc cleanUp(c: PPassContext, n: PNode): PNode =
|
||||
var s: PSym
|
||||
result = n
|
||||
# we cannot clean up if dead code elimination is activated
|
||||
if optDeadCodeElim in gGlobalOptions: return
|
||||
|
|
@ -36,9 +39,9 @@ proc cleanUp(c: PPassContext, n: PNode): PNode =
|
|||
of nkStmtList:
|
||||
for i in countup(0, sonsLen(n) - 1): discard cleanup(c, n.sons[i])
|
||||
of nkProcDef, nkMethodDef:
|
||||
if (n.sons[namePos].kind == nkSym):
|
||||
s = n.sons[namePos].sym
|
||||
if not (sfDeadCodeElim in getModule(s).flags) and not astNeeded(s):
|
||||
if n.sons[namePos].kind == nkSym:
|
||||
var s = n.sons[namePos].sym
|
||||
if sfDeadCodeElim notin getModule(s).flags and not astNeeded(s):
|
||||
s.ast.sons[codePos] = ast.emptyNode # free the memory
|
||||
else:
|
||||
nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue