Author: wyoung
Date: Tue May 18 03:50:54 2010
New Revision: 2640
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2640&view=rev
Log:
No longer smashing field name case on FieldNames object init. Using
case-insensitive comparisons in operator[] instead. This is less
efficient because we could just smash the operator[]() argument the same
way we did in the ctor, but now we potentially have to smash all field
name case on each operator[] call, but this is likely to be
insiginficant compared to the remote RDBMS overheads.
Modified:
trunk/lib/field_names.cpp
Modified: trunk/lib/field_names.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/field_names.cpp?rev=2640&r1=2639&r2=2640&view=diff
==============================================================================
--- trunk/lib/field_names.cpp (original)
+++ trunk/lib/field_names.cpp Tue May 18 03:50:54 2010
@@ -2,7 +2,7 @@
field_names.cpp - Implements the FieldNames class.
Copyright (c) 1998 by Kevin Atkinson, (c) 1999-2001 by MySQL AB, and
- (c) 2004-2009 by Educational Technology Resources, Inc. Others may
+ (c) 2004-2010 by Educational Technology Resources, Inc. Others may
also hold copyrights on code in this file. See the CREDITS.txt file
in the top directory of the distribution for details.
@@ -43,9 +43,7 @@
reserve(num);
for (size_t i = 0; i < num; i++) {
- std::string p(res->fields().at(i).name());
- internal::str_to_lwr(p);
- push_back(p);
+ push_back(res->fields().at(i).name());
}
}
@@ -53,9 +51,17 @@
unsigned int
FieldNames::operator [](const std::string& s) const
{
- std::string temp(s);
- internal::str_to_lwr(temp);
- return static_cast<unsigned int>(std::find(begin(), end(), temp) -
begin());
+ std::string temp1(s);
+ internal::str_to_lwr(temp1);
+ for (const_iterator it = begin(); it != end(); ++it) {
+ std::string temp2(*it);
+ internal::str_to_lwr(temp2);
+ if (temp2.compare(temp1) == 0) {
+ return it - begin();
+ }
+ }
+
+ return end() - begin();
}
} // end namespace mysqlpp
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits