A closure can be used to avoid creating garbage here. The style function would like

```js
var styleFunction = function(feature, resolution) {
  return styles[feature.getGeometry().getType()];
};
```

This "technique" is already used for the overlay style.