# link.Elf: avoid needless file system reads in flush\(\) · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/31d70cb1e11cf480f4a45afdff20e4adf0d6068b)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 31d70cb1e11cf480f4a45afdff20e4adf0d6068b

Requested commit: 31d70cb1e11cf480f4a45afdff20e4adf0d6068b

Commit: 31d70cb1e11cf480f4a45afdff20e4adf0d6068b

Tree: 384541411c9b2be3192232cb90b1d43d98351c1f

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
link.Elf: avoid needless file system reads in flush()

flush() must not do anything more than necessary. Determining the type
of input files must be done only once, before flush. Fortunately, we
don't even need any file system accesses to do this since that
information is statically known in most cases, and in the rest of the
cases can be determined by file extension alone.

This commit also updates the nearby code to conform to the convention
for error handling where there is exactly one error code to represent
the fact that error messages have already been emitted. This had the
side effect of improving the error message for a linker script parse
error.

"positionals" is not a linker concept; it is a command line interface
concept. Zig's linker implementation should not mention "positionals".
This commit deletes that array list in favor of directly making function
calls, eliminating that heap allocation during flush().

```

## Parents

- [2c41c453b634b3d1f378f6f1b335314f0a4be2de](https://git.cafe/gitcafe/zig/commit/2c41c453b634b3d1f378f6f1b335314f0a4be2de?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/31d70cb1e11cf480f4a45afdff20e4adf0d6068b?format=markdown)
