Skip to content

Commit 0f97665

Browse files
committed
Faster initialization of attributes
1 parent 578dc2a commit 0f97665

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/core/qgsfeature.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ void QgsFeature::setValid( bool validity )
158158
mValid = validity;
159159
}
160160

161+
void QgsFeature::initAttributes( int fieldCount )
162+
{
163+
mAttributes.resize( fieldCount );
164+
QVariant* ptr = mAttributes.data();
165+
for ( int i = 0; i < fieldCount; ++i, ++ptr )
166+
ptr->clear();
167+
}
168+
169+
161170
bool QgsFeature::setAttribute( const QString& name, QVariant value )
162171
{
163172
int fieldIdx = fieldNameIndex( name );

src/core/qgsfeature.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class CORE_EXPORT QgsFeature
141141
QgsAttributes& attributes() { return mAttributes; }
142142
void setAttributes( const QgsAttributes& attrs ) { mAttributes = attrs; }
143143
void setAttribute( int field, const QVariant& attr ) { mAttributes[field] = attr; }
144-
void initAttributes( int fieldCount ) { mAttributes.resize( fieldCount ); for ( int i = 0;i < fieldCount;++i ) mAttributes[i].clear(); }
144+
void initAttributes( int fieldCount );
145145

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

0 commit comments

Comments
 (0)