[Xapian-devel] mutable Query objects
Olly Betts
olly at survex.com
Thu Feb 24 21:04:37 GMT 2005
On Thu, Feb 24, 2005 at 06:04:20PM +0000, Richard Boulton wrote:
> On Thu, 2005-02-24 at 16:54 +0000, Olly Betts wrote:
> > (a) implement a "deep copy" clone for Query objects and use it in
> > Enquire::set_query()
> >
> > (b) make Query object immutable by replacing these non-const public
> > methods with extra constructor parameters:
>
> I'd favour (b) too. The query objects aren't usefully mutable, anyway
> (I can't think of a situation where it would be useful to take advantage
> of them being mutable), so it would be a waste of coding and testing
> time to implement a deep copy operation.
True, it seems to add complexity without a good reason.
> Also, it would mean that a
> deep copy had to be performed every time a query is set, which currently
> doesn't need to happen, so it will slow down the common case.
That's true.
Actually, there's a (c) - use copy-on-write to elide the deep copy in
the common case. But that's also needless complication really.
OK, I'll implement (b).
Cheers,
Olly
More information about the Xapian-devel
mailing list