Skip to content

Commit

Permalink
Faster initialization of attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Dec 28, 2012
1 parent 578dc2a commit 0f97665
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/core/qgsfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 0f97665

Please sign in to comment.