We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5d83283 commit fae0152Copy full SHA for fae0152
lib/stackprof/report.rb
@@ -10,10 +10,14 @@ class Report
10
11
class << self
12
def from_file(file)
13
- if (content = IO.binread(file)).start_with?(MARSHAL_SIGNATURE)
14
- new(Marshal.load(content))
15
- else
16
- from_json(JSON.parse(content))
+ File.open(file, 'rb') do |f|
+ signature_bytes = f.read(2)
+ f.rewind
+ if signature_bytes == MARSHAL_SIGNATURE
17
+ new(Marshal.load(f))
18
+ else
19
+ from_json(JSON.parse(f.read))
20
+ end
21
end
22
23
0 commit comments