bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #35485] New $(.MFDIR) built-in variable


From: Paul Smith
Subject: Re: [bug #35485] New $(.MFDIR) built-in variable
Date: Sun, 26 Feb 2012 19:21:22 -0500

On Thu, 2012-02-09 at 17:25 +0000, Tim Murphy wrote:
> I also think that it can be expensive to append things onto very long
> lists in make but that's just suspicion and I really need to take a
> proper look at it instead of making accusations. 

Appending is not very expensive.  Make doesn't know anything about
"lists" internally.  Everything in make is a string.  If you append to a
variable then make basically does a strlen() of the string, makes sure
there's enough memory for the new content in the buffer (or if not,
reallocs enough space), then strcat()'s the value.  Or the equivalent.
So I suppose yes, in some ways the longer the string the longer it takes
to do the strlen() but this should be very fast I'd expect.  Much of the
string manipulation in make (and make does a LOT of string manipulation)
is bog-stupid strlen, strcat, strcpy, strdup which gets expensive in
some situations.  I've considered implementing some kind of fancy string
encoding .

The thing that DOES get noticeably more complex is manipulating the
variable as if it were a list, with functions like firstword, lastword,
etc. because those functions must first chop the string up into words,
then operate on those, and that happens every time the function is
invoked.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]