optimise response construction when no truncation is required

no need to do a binary search if all the answers fit
This commit is contained in:
Matthias Radestock committed 2015-08-20 20:18:56 +01:00
1 parent 2ea27ec08f
commit 9a7abe68fd
1 file changed
+2 -2
+2 -2
View File
@@ -246,10 +246,10 @@ func (h *handler) makeResponse(req *dns.Msg, answers []dns.RR) *dns.Msg {
response.SetReply(req)
response.RecursionAvailable = true
response.Authoritative = true
response.Answer = answers
maxSize := h.getMaxResponseSize(req)
if len(answers) <= 1 || maxSize <= 0 {
response.Answer = answers
if len(answers) <= 1 || maxSize <= 0 || response.Len() <= maxSize {
return response
}