diff options
| author | 2021-08-29 21:48:14 -0700 | |
|---|---|---|
| committer | 2021-08-29 21:48:14 -0700 | |
| commit | bd9f137b1bfb5bc3b215515ff9305e70a638daf9 (patch) | |
| tree | e2a252e2b2478b6b1fb7cd23eb90e4da9c5bc8cd /src/fs.zig | |
| parent | 34792c15f188d0c480d64022a9d3a67a89497c70 (diff) | |
| download | bun-bd9f137b1bfb5bc3b215515ff9305e70a638daf9.tar.gz bun-bd9f137b1bfb5bc3b215515ff9305e70a638daf9.tar.zst bun-bd9f137b1bfb5bc3b215515ff9305e70a638daf9.zip | |
latest
Former-commit-id: 096ec1222ad723d006b0151f10cb0c1b95e2bfd3
Diffstat (limited to 'src/fs.zig')
| -rw-r--r-- | src/fs.zig | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/fs.zig b/src/fs.zig index 3936ea933..e59d24b6f 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -16,7 +16,7 @@ const hash_map = @import("hash_map.zig"); pub const Preallocate = struct { pub const Counts = struct { pub const dir_entry: usize = 512; - pub const files: usize = 1024; + pub const files: usize = 4096; }; }; @@ -810,7 +810,7 @@ pub const FileSystem = struct { ) !File { FileSystem.setMaxFd(file.handle); - if (FeatureFlags.disable_filesystem_cache) { + if (comptime FeatureFlags.disable_filesystem_cache) { _ = std.os.fcntl(file.handle, std.os.F_NOCACHE, 1) catch 0; } @@ -820,6 +820,18 @@ pub const FileSystem = struct { return err; }); + // Skip the pread call for empty files + // Otherwise will get out of bounds errors + // plus it's an unnecessary syscall + if (size == 0) { + if (comptime use_shared_buffer) { + shared_buffer.reset(); + return File{ .path = Path.init(path), .contents = shared_buffer.list.items }; + } else { + return File{ .path = Path.init(path), .contents = "" }; + } + } + var file_contents: []u8 = undefined; // When we're serving a JavaScript-like file over HTTP, we do not want to cache the contents in memory |
