about summary refs log tree commit diff stats
path: root/src/luasocket
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-20 23:35:22 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-11-20 23:35:22 -0800
commit15b43d3092a344897d3785fee97b347dcfb4d326 (patch)
tree2b743d9712297a37b3618effd60b8458ac7334ac /src/luasocket
parent548d59f918eb9d370053596b5166f09b4e5e00c5 (diff)
downloadteliva-15b43d3092a344897d3785fee97b347dcfb4d326.tar.gz
drop some redundant `require`s
Diffstat (limited to 'src/luasocket')
-rw-r--r--src/luasocket/socket.lua21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/luasocket/socket.lua b/src/luasocket/socket.lua
index 303f04d..33689f9 100644
--- a/src/luasocket/socket.lua
+++ b/src/luasocket/socket.lua
@@ -3,13 +3,6 @@
 -- Author: Diego Nehab
 -----------------------------------------------------------------------------
 
------------------------------------------------------------------------------
--- Declare module and import dependencies
------------------------------------------------------------------------------
-local base = _G
-local string = require("string")
-local math = require("math")
-
 local _M = socket
 
 -----------------------------------------------------------------------------
@@ -29,7 +22,7 @@ function _M.bind(host, port, backlog)
     if not addrinfo then return nil, err end
     local sock, res
     err = "no info on address"
-    for i, alt in base.ipairs(addrinfo) do
+    for i, alt in ipairs(addrinfo) do
         if alt.family == "inet" then
             sock, err = socket.tcp4()
         else
@@ -56,11 +49,11 @@ _M.try = _M.newtry()
 
 function _M.choose(table)
     return function(name, opt1, opt2)
-        if base.type(name) ~= "string" then
+        if type(name) ~= "string" then
             name, opt1, opt2 = "default", name, opt1
         end
         local f = table[name or "nil"]
-        if not f then base.error("unknown key (".. base.tostring(name) ..")", 3)
+        if not f then error("unknown key (".. tostring(name) ..")", 3)
         else return f(opt1, opt2) end
     end
 end
@@ -76,7 +69,7 @@ _M.sinkt = sinkt
 _M.BLOCKSIZE = 2048
 
 sinkt["close-when-done"] = function(sock)
-    return base.setmetatable({
+    return setmetatable({
         getfd = function() return sock:getfd() end,
         dirty = function() return sock:dirty() end
     }, {
@@ -90,7 +83,7 @@ sinkt["close-when-done"] = function(sock)
 end
 
 sinkt["keep-open"] = function(sock)
-    return base.setmetatable({
+    return setmetatable({
         getfd = function() return sock:getfd() end,
         dirty = function() return sock:dirty() end
     }, {
@@ -106,7 +99,7 @@ sinkt["default"] = sinkt["keep-open"]
 _M.sink = _M.choose(sinkt)
 
 sourcet["by-length"] = function(sock, length)
-    return base.setmetatable({
+    return setmetatable({
         getfd = function() return sock:getfd() end,
         dirty = function() return sock:dirty() end
     }, {
@@ -123,7 +116,7 @@ end
 
 sourcet["until-closed"] = function(sock)
     local done
-    return base.setmetatable({
+    return setmetatable({
         getfd = function() return sock:getfd() end,
         dirty = function() return sock:dirty() end
     }, {