I would do:

```
int service = 0;
for loop at ln 215...
{
  if (addonIt->ID() == defaultService)
    service = std::distance(addonIt, addons.begin());
}
```

i.e. you needn't have the two loops.