file_writer 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/file_writer/version.rb +1 -1
- data/lib/file_writer.rb +1 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 445e82401dfafee9e2f5649b49311c4f6c9732741dc678d0f5ac0094142a3b1d
|
4
|
+
data.tar.gz: e5acc85f0ddf4cdcdf3160bb5729273ea26a9c35e56916a885804ba3549394d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d94b7a8b5ab8b4f11da380b052d1872da96a7b4be9b846a1db57a8ae1e9288c10fe1d9f4440438317931b83c14c6a0e46aa9f8e72825c74202d54b49507f91a
|
7
|
+
data.tar.gz: e3fe075b9bbc047b6a48fe8961b881674c122cbfb0f347ffece183dc4d86257a24f5dc8131a2217b3a369fee9630e5f8d9c56ae7195b98eebefe6e218ef4d4dd
|
data/lib/file_writer/version.rb
CHANGED
data/lib/file_writer.rb
CHANGED
@@ -40,27 +40,7 @@ class FileWriter
|
|
40
40
|
File.open(fname, "wb+", fmode) do |f|
|
41
41
|
size = contents.bytesize
|
42
42
|
|
43
|
-
|
44
|
-
#We do this rather than f.write or f.syswrite as it
|
45
|
-
# gives substantially better latency in a threaded
|
46
|
-
# environment as of MRI 2.7.2 than a single write,
|
47
|
-
# at the cost of throughput
|
48
|
-
#
|
49
|
-
# See tests/latency.rb for a test case, and try
|
50
|
-
# replacing the below with
|
51
|
-
#
|
52
|
-
# ```
|
53
|
-
# written = File.write(contents)
|
54
|
-
# ```
|
55
|
-
#
|
56
|
-
written = 0
|
57
|
-
while (size - written) > SPLIT_SIZE
|
58
|
-
if (w = f.write(contents[written .. (written+SPLIT_SIZE-1)])) != SPLIT_SIZE
|
59
|
-
raise SystemCallError.new("FileWriter#write: write returned unexpected length (#{w.inspect})")
|
60
|
-
end
|
61
|
-
written += w
|
62
|
-
end
|
63
|
-
written += f.write(contents[written .. -1])
|
43
|
+
written = f.write(contents)
|
64
44
|
|
65
45
|
if written != size
|
66
46
|
raise SystemCallError.new("FileWriter#write: write returned unexpected length")
|