I think there's a few confusions in your question, but here are some points you should look into :
As others pointed out, only draw the terrain tiles that are actually on screen. You do not need to draw the whole world at each frame.
If you world dosen't change (or doesn't change much except by player's action), you could try to render it once and for all and cache this rendering into a texture that you would display (with the good offset corresponding to the in-game position of the player). No more looping through tiles and arrays. Take a look at
RenderTexture
. Of course if your player can dig or do whatever changes the world, you can't use this texture forever, but it may be a good idea to do it after every change, as changes don't happen so often compared to rendering, so I guess you could still benefit from this.You mentionned an array of sprites. I hope you don't have an instance of a
sf::Sprite
for every single grass tile, every single rock tile etc. ? In case you do, only have one sprite of each tile, and use it to draw every tiles of its type just by changing its coordinates and drawing it to your render target. But I may have misunderstood your question.