Best practice for fixtures/bodies?

Ok, so I have one static body to represent the walls in my game. I have box shaped fixtures to hold the data for these walls. There can potentially be thousands of separate walls in my game and I'm not sure how many Box2D can handle. The player can only collide with the ones close to him though so I thought of deleting the fixtures each frame and recreating the closest 20 or so to the player(actually first I thought of changing the fixture's shape's position but I'm not sure f I can do that). This seems good but I'm not sure how to iterate through the fixtures:

Code:
for (b2Fixture* f = collisionBody->GetFixtureList(); f; f = f->GetNext())
   {
      collisionBody->DestroyFixture(f);

   }


This of course destroys the fixture pointer that the loop is using(EDIT:So only one of my fixtures is getting destroyed then). This is more of a general newbie C++ question I guess but I'm sure someone could help 🙂 Also, I'm wondering if it's better to destroy/recreate the body each frame so I don't have to loop through all the fixtures to destroy them.
Just do the GetNext before you do the DestroyFixture:
Code:
for (b2Fixture* f = collisionBody->GetFixtureList(); f; )
{
    b2Fixture* fixtureToDestroy = f;
    f = f->GetNext();
    collisionBody->DestroyFixture( fixtureToDestroy );
}

However, if you have one static body to represent all the walls, this will destroy all of them... probably not what you want.

Fixtures on static bodies are the fastest kind to do collision detection with. It would take longer to remove and replace fixtures in the dynamic tree than just to keep everything unchanged. I would not bother trying to optimize anything here unless it really is a problem.
Yeah, I don't think destroying and recreating fixtures is faster than just keeping them there the entire time.

Original thread: https://box2d.org/forum/viewtopic.php?t=8414