cloudwu / sproto

Yet another protocol library like google protocol buffers , but simple and fast.
MIT License
942 stars 253 forks source link

review sprotoparser.lua 源码 if ptype then 这个逻辑分支理论上应该一直不会执行 #68

Closed quzhujian2031 closed 7 years ago

quzhujian2031 commented 7 years ago
local function checktype(types, ptype, t)
        if buildin_types[t] then
               return t
    end
    local fullname = ptype .. "." .. t
    if types[fullname] then
        return fullname
    else
        ptype = ptype:match "(.+)%..+$"
        if ptype then
            return checktype(types, ptype, t)
        elseif types[t] then
            return t
        end
    end
end

if ptype then 这个逻辑分支理论上应该一直不会执行,因为按照逻辑所有 ptype 都不会匹配"(.+)%..+$"