How to deal with pixel-per-pixel operations?
      
        Hello, I'm starting to write a GIMP plugin and I'm facing the problem of "pixel-per-pixel" algorithms and their speed.
Without going on details, my algorithm should take every pixel in the image and for each one it must check its 24 neighbours, it does some simple calcs and finally it set a new color for the pixel.
How to speed-up the execution? I tried with the easiest approach with a classic "for-in-for" loop but the computation is really slow. Looking around, I've seen some GIMP functions like:
gimppixelfetcher  Functions for operating on pixel regions.
gimppixelrgn  Functions for operating on pixel regions.
gimpregioniterator  Functions to traverse a pixel regions. 
Can they help me? I can't actually understand well how they work because the GIMP-dev reference is incomplete in several parts...
Is there, maybe, some code snippets or tutorial about this problem?
Thank you for your support,
Ale