Backport file_expand memory usage fix

From https://bugs.ruby-lang.org/issues/9934

Before:

```
$ ruby -e' GitHub.preload_all; GC.start; p GitHub::Memory.memrss '
395558912
```

After:

```
$ ruby -e' GitHub.preload_all; GC.start; p GitHub::Memory.memrss '
373579776
```