[Liblas-commits] hg: Do not use stringstream where not not
necessary. Mark some v...
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Oct 26 19:45:11 EDT 2010
changeset 4c84ffb7b8d5 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=4c84ffb7b8d5
summary: Do not use stringstream where not not necessary. Mark some values ast constants to make them optimisation-friendly. Tidy up.
diffstat:
src/lasdimension.cpp | 28 +++++++++++++---------------
1 files changed, 13 insertions(+), 15 deletions(-)
diffs (71 lines):
diff -r 1a64145ea9c5 -r 4c84ffb7b8d5 src/lasdimension.cpp
--- a/src/lasdimension.cpp Wed Oct 27 00:43:04 2010 +0100
+++ b/src/lasdimension.cpp Wed Oct 27 00:44:58 2010 +0100
@@ -77,12 +77,11 @@
m_byte_offset(0),
m_bit_offset(0)
{
- if (size_in_bits == 0) {
- std::ostringstream oss;
- oss << "The bit size of the dimension is 0, the dimension is invalid.";
- throw std::runtime_error(oss.str());
+ if (0 == size_in_bits)
+ {
+ throw std::runtime_error("The bit size of the dimension is 0, the dimension is invalid.");
}
-};
+}
/// copy constructor
Dimension::Dimension(Dimension const& other) :
@@ -101,8 +100,8 @@
, m_bit_offset(other.m_bit_offset)
{
}
-//
-// // assignment constructor
+
+/// assignment operator
Dimension& Dimension::operator=(Dimension const& rhs)
{
if (&rhs != this)
@@ -127,9 +126,9 @@
std::size_t Dimension::GetByteSize() const
{
-
- std::size_t bit_position = m_bit_size % 8;
- if (bit_position > 0) {
+ std::size_t const bit_position = m_bit_size % 8;
+ if (bit_position > 0)
+ {
// For dimensions that are not byte aligned,
// we need to determine how many bytes they
// will take. We have to read at least one byte if the
@@ -160,9 +159,10 @@
dim.put("bitoffset" , GetBitOffset());
dim.put("bytesize", GetByteSize());
- if (IsNumeric()) {
+ if (IsNumeric())
+ {
if (! (detail::compare_distance(GetMinimum(), GetMaximum() )
- && detail::compare_distance(0.0, GetMaximum())))
+ && detail::compare_distance(0.0, GetMaximum())))
{
dim.put("minimum", GetMinimum());
dim.put("maximum", GetMaximum());
@@ -174,12 +174,10 @@
std::ostream& operator<<(std::ostream& os, liblas::Dimension const& d)
{
-
using liblas::property_tree::ptree;
ptree tree = d.GetPTree();
- std::string name = tree.get<std::string>("name");
-
+ std::string const name = tree.get<std::string>("name");
os << "'" << name << "'" << " -- ";
os << " size: " << tree.get<boost::uint32_t>("size");
More information about the Liblas-commits
mailing list