Skip to content
Permalink
Browse files
Faster initialization of attributes
  • Loading branch information
wonder-sk committed Dec 28, 2012
1 parent 578dc2a commit 0f97665337570ae1ba0f8a41a314ce6926bc61cc
Showing with 10 additions and 1 deletion.
  1. +9 −0 src/core/qgsfeature.cpp
  2. +1 −1 src/core/qgsfeature.h
@@ -158,6 +158,15 @@ void QgsFeature::setValid( bool validity )
mValid = validity;
}

void QgsFeature::initAttributes( int fieldCount )
{
mAttributes.resize( fieldCount );
QVariant* ptr = mAttributes.data();
for ( int i = 0; i < fieldCount; ++i, ++ptr )
ptr->clear();
}


bool QgsFeature::setAttribute( const QString& name, QVariant value )
{
int fieldIdx = fieldNameIndex( name );
@@ -141,7 +141,7 @@ class CORE_EXPORT QgsFeature
QgsAttributes& attributes() { return mAttributes; }
void setAttributes( const QgsAttributes& attrs ) { mAttributes = attrs; }
void setAttribute( int field, const QVariant& attr ) { mAttributes[field] = attr; }
void initAttributes( int fieldCount ) { mAttributes.resize( fieldCount ); for ( int i = 0;i < fieldCount;++i ) mAttributes[i].clear(); }
void initAttributes( int fieldCount );

/**Deletes an attribute and its value*/
void deleteAttribute( int field );

0 comments on commit 0f97665

Please sign in to comment.