The change on this line is an optimization: calling erase() will re-lock the mutex for each marker.  Moving the code from erase() here avoids that overhead.