monotone-devel
[Top][All Lists]
Advanced

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

Re: [Monotone-devel] Typesafe VA_ARGS replacement for database::execute/


From: Nathaniel Smith
Subject: Re: [Monotone-devel] Typesafe VA_ARGS replacement for database::execute/fetch
Date: Sat, 21 Jan 2006 22:24:36 -0800
User-agent: Mutt/1.5.9i

On Sat, Jan 21, 2006 at 03:11:51AM -0600, Timothy Brownawell wrote:
> On Fri, 2006-01-20 at 20:03 -0800, Nathaniel Smith wrote:
> > Since we shovel hundreds of megabytes through this interface, reducing
> > copying seems worthwhile.  I guess we do always copy now, though, so
> > actually I guess I have no data on whether the win is valuable or not.
> > We spend a lot of time in sqlite, but I don't know where exactly.
> 
> Aren't strings copy-on-write anyway, so this shouldn't be a problem?

Oh, hrm.  That's a clever point.

It does look like everything we ever bind is already in a std::string.

So, true.  Perhaps the best answer (Vinzenz is going to kill me) is to
go back to the %-style, with something like:

struct query_arg
  {
    enum type_t { text, blob };
    type_t const type;
    std::string const value;
    query_arg(type_t type, std::string const & value)
      : type(type), value(value)
      {}
  };

struct query
  {
    query(char const * query_string) : query_string(query_string) {}
    operator % (query_arg const & qa)
      { args.append(query_arg); }
    std::string const query_string;
    std::vector<query_arg> args;
  }

query_arg
blob(std::string const & value)
  {
    return query_arg(query_arg::blob, value);
  }

query_arg
text(std::string const & value)
  {
    return query_arg(query_arg::text, value);
  }

?

-- Nathaniel

-- 
.i dei jitfa fanmo xatra




reply via email to

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