def compact(self):
        """Remove all invalid config entries."""

        saved_length = 0
        to_remove = []
        for i, entry in enumerate(self.entries):
            if not entry.valid:
                to_remove.append(i)
                saved_length += entry.data_space()

        for i in reversed(to_remove):
            del self.entries[i]

        self.data_index -= saved_length
Remove all invalid config entries.