Skip to content

Commit

Permalink
Enforce Int64 regardless of word-size for protos
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly committed Aug 1, 2019
1 parent fdcf20f commit 9bf570d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/PProf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ import .perftools.profiles: ValueType, Sample, Function,
const PProfile = perftools.profiles.Profile

"""
_enter!(dict::OrderedDict{T, Int}, key::T) where T
_enter!(dict::OrderedDict{T, Int64}, key::T) where T
Resolves from `key` to the index (zero-based) in the dict.
Useful for the Strings table
NOTE: We must use Int64 throughout this package (regardless of system word-size) b/c the
proto file specifies 64-bit integers.
"""
function _enter!(dict::OrderedDict{T, Int}, key::T) where T
function _enter!(dict::OrderedDict{T, Int64}, key::T) where T
if haskey(dict, key)
return dict[key]
else
l = length(dict)
l = Int64(length(dict))
dict[key] = l
return l
end
Expand Down Expand Up @@ -84,7 +87,7 @@ function pprof(data::Union{Nothing, Vector{UInt}} = nothing,
period = ccall(:jl_profile_delay_nsec, UInt64, ())
end

string_table = OrderedDict{AbstractString, Int}()
string_table = OrderedDict{AbstractString, Int64}()
enter!(string) = _enter!(string_table, string)
enter!(::Nothing) = _enter!(string_table, "nothing")
ValueType!(_type, unit) = ValueType(_type = enter!(_type), unit = enter!(unit))
Expand Down

0 comments on commit 9bf570d

Please sign in to comment.