[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A practical code analysis question
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 14 Feb 2012 17:13:02 -0200
> In particular we want to find the string concatenations in loops:
> local foo = ...
> for ... do
> foo = something .. foo .. something .. else
Wouldn't be easier to find string concatenations used with accumulators?
I guess the following pattern (for plain Lua pattern matching),
applied at each line of the program, would be a good filter:
p = "^%s*([a-zA-Z_][a-zA-Z0-9_]*)%s*=.*%1%s*%.%."
You may also need this other one:
p = "^%s*([a-zA-Z_][a-zA-Z0-9_]*)%s*=.*%.%.%s*%1"
(You may need to change it something if you want to detect accumulation
over a table field, like a.x = a.x .. something...)