inline bool collect_header()

in src/filtration/filtratorimpl.h [253:293]


    inline bool collect_header(PacketInfo& info, size_t callHeaderLen, size_t replyHeaderLen)
    {
        if(collection && (collection.data_size() > 0)) // collection is allocated
        {
            assert(collection.capacity() >= callHeaderLen);
            const size_t tocopy{callHeaderLen - collection.data_size()};
            assert(tocopy != 0);
            if(info.dlen < tocopy)
            {
                collection.push(info, info.dlen);
                info.data += info.dlen; // optimization
                info.dlen = 0;
                return false;
            }
            else // info.dlen >= tocopy
            {
                collection.push(info, tocopy); // collection.data_size <= header_len
                info.dlen -= tocopy;
                info.data += tocopy;
            }
        }
        else // collection is empty
        {
            collection.allocate();         // allocate new collection from writer
            if(info.dlen >= callHeaderLen) // is data enough to message validation?
            {
                collection.push(info, callHeaderLen); // probability that message will be rejected / probability of valid message
                info.data += callHeaderLen;
                info.dlen -= callHeaderLen;
            }
            else // (info.dlen < header_len)
            {
                collection.push(info, info.dlen);
                //info.data += info.dlen;//   optimization
                size_t copied = info.dlen;
                info.dlen     = 0;
                return copied >= replyHeaderLen;
            }
        }
        return true;
    }