From 70b40f67824b3d612235c382aa83821c054fa51e Mon Sep 17 00:00:00 2001 From: jussi Date: Wed, 17 Apr 2024 00:35:58 +0300 Subject: Object libraries like Vector2 optimizations. --- examples/resources/lib/rune.lua | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'examples/resources/lib/rune.lua') diff --git a/examples/resources/lib/rune.lua b/examples/resources/lib/rune.lua index fa9f59d..12bf72d 100644 --- a/examples/resources/lib/rune.lua +++ b/examples/resources/lib/rune.lua @@ -21,27 +21,15 @@ local metatable = { } function Rune:new( string ) - if type( string ) == "table" then - string = RL.LoadUTF8( string ) - elseif type( string ) == "nil" then - string = "" - end - local object = setmetatable( {}, metatable ) - object.string = string + object.string = string or "" return object end function Rune:set( string ) - if type( string ) == "table" then - string = RL.LoadUTF8( string ) - elseif type( string ) == "nil" then - string = "" - end - - self.string = string + self.string = string or "" end function Rune:clone() @@ -57,12 +45,12 @@ function Rune:getCodepoints() end function Rune:getCodepoint( index ) - local codepoint = RL.GetCodepoint( self:sub( index, index ) ) + local codepoint = RL.GetCodepoint( self.string, index ) return codepoint end function Rune:getCodepointSize( index ) - local _, codepointSize = RL.GetCodepoint( self:sub( index, index ) ) + local _, codepointSize = RL.GetCodepoint( self.string, index ) return codepointSize end -- cgit v1.2.3