hadley/ggplot2 — pull request #699 by wch (2012-10-22 22:40:35+00:00)
Title: Draw geom_polygon as a single grob

This fixes #666.

These are the times with the old version (ggplot2 0.9.2.1). First is `geom_polygon`, then `geom_path`:

```R
library(ggplot2)
library(maps)
system.time(print(ggplot(map_data("world")) + geom_polygon(aes(long, lat, group = group))))
# user system elapsed
# 11.701 0.247 46.543
system.time(print(ggplot(map_data("world")) + geom_path(aes(long, lat, group = group))))
# user system elapsed
# 2.802 0.123 3.044
```

These are the times after the fix:

```R
library(ggplot2)
library(maps)
system.time(print(ggplot(map_data("world")) + geom_polygon(aes(long, lat, group = group))))
# user system elapsed
# 0.922 0.098 1.157
system.time(print(ggplot(map_data("world")) + geom_path(aes(long, lat, group = group))))
# user system elapsed
# 3.038 0.146 3.319
```

`geom_polygon` is now about 12.5x faster than it was before -- and it's now 3x faster than `geom_path`. Not bad!