[GIS] IFeatureBuffer – performance considerations (ArcObjects)

arcobjectsbufferperformance

I'm trying to optimize my code to make it faster. I have a loop that reads some string input and creates points with the help of IFeatureBuffer and IFeatureCursor.

If I create the buffer inside tho loop, it slows the code down.

For i = 0 To Counter
  pFBuffer = pFClass.CreateFeatureBuffer
  ...
  pFBuffer.Value(iField) = ...
  pFCursor.InsertFeature(pFBuffer)
Next

If I move pFBuffer = pFClass.CreateFeatureBuffer above the loop (i.e. create the buffer once only) it works significantly faster. However, I have to "clear" the buffer at the end of each iteration, as in some cases it stores values from previous iterations.

So the question is: how can I clear the buffer, so that I won't need to create it at each iteration? Are there any other drawbacks or things to consider?

Best Answer

how can I clear the buffer, so that I won't need to create it at each iteration?

You could loop through each field of the featurebuffer and if IField.Editable is true set the value of the featurebuffer to IField.DefaultValue. Take special care if you have subtypes.

Related Question