From 4b267df93ee602bab290a379c0ccfe9b2c4b77a6 Mon Sep 17 00:00:00 2001 From: ronkorving Date: Wed, 16 Dec 2015 11:09:13 +0900 Subject: [PATCH] udp: remove a needless instanceof Buffer check When a string is passed to udpsock.send, it is automatically converted to a Buffer. In that case, it is no longer needed to test whether or not the argument is a Buffer or not. PR-URL: https://github.com/nodejs/node/pull/4301 Reviewed-By: Colin Ihrig Reviewed-By: Brian White Reviewed-By: Roman Reiss --- lib/dgram.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/dgram.js b/lib/dgram.js index e172e413241993..b8ffb1f92c5790 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -252,8 +252,7 @@ Socket.prototype.send = function(buffer, if (typeof buffer === 'string') buffer = new Buffer(buffer); - - if (!(buffer instanceof Buffer)) + else if (!(buffer instanceof Buffer)) throw new TypeError('First argument must be a buffer or string'); offset = offset | 0;