Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2004-04-06 14:03:59

David Abrahams wrote:

> Well if we could solve problem #1, the expense of the initial
> construction becomes a non-issue for my case, because I'd only have
> to search once. And regardless of all that, often convenience is
> *way* more important than efficiency.
> That said, as long as the match object is immutable, there's little
> to worry about w.r.t. thread safety.

Here there be dragons. An immutable match object is appealing, but the
performance would be problematic. The match object is essentially a
std::vector of sub-matches, dynamically allocated because you don't know
how many sub-matches there will be until runtime.

Often, you want to match the same pattern repeatedly. In that case, you
reuse the match object and avoid the extra allocations. Forcing the
creation of a new match object each time would be a terrible pessimization.

I'm all for ease-of-use, as long as accommodation is made for those who
care about speed.

Eric Niebler
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at