From: Llew Sion Goodstadt <leo.goodstadt@human-anatomy.oxford.ac.uk>
To: pgsql-interfaces@postgresql.org
Subject: Re: libpqxx testers needed!
Date: Tue, 3 Dec 2002 17:08:20 -0000
Message-ID: <00d501c29aee$9484a490$1c1d01a3@FGU028> (raw)
In-Reply-To: <20021203010907.GD1385@localhost>
One thing I am curious about is why strings are passed by value instead
of by constant reference.
Even granted that many standard library vendors *in the past* used
COW reference counting implementations of std::string to minimize the
cost of copying, this surely is still an unwarranted additional cost.
E.g. libpqxx-1.2.2\src\connection.cxx:427
Instead of:
void pqxx::Connection::BeginCopyRead(string Table)
Should be:
void pqxx::Connection::BeginCopyRead(const string& Table)
{
Result R( Exec(("COPY " + Table + " TO STDOUT").c_str()) );
R.CheckStatus();
}
Of course if you are going to change the string anyway inside the body
of the function, pass by const
reference is misleading for both the compiler and the user, so pass
by value would be justified. E.g. if the above example had been
something like
void pqxx::Connection::BeginCopyRead(string Table)
{
Table = "COPY " + Table + " TO STDOUT";
Result R( Exec(Table.c_str()) );
R.CheckStatus();
}
I have found few of these cases in libpqxx.
Leo Goodstadt
MRC Functional Genetics Unit
OXFORD
OX1 3QX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: leo.goodstadt@human-anatomy.oxford.ac.uk
Subject: Re: libpqxx testers needed!
In-Reply-To: <00d501c29aee$9484a490$1c1d01a3@FGU028>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox