Improved performance
This commit is contained in:
parent
75f386b03a
commit
2259a83d76
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.lua -crlf
|
||||||
|
*.h -crlf
|
||||||
|
*.c -crlf
|
18
Makefile
18
Makefile
@ -1,5 +1,9 @@
|
|||||||
|
# TARGET=arm-none-eabi
|
||||||
|
|
||||||
|
#CC=$(TARGET)-gcc
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-g -std=gnu99 -Isrc/lib/lua -Iinclude
|
|
||||||
|
CFLAGS=-O2 -std=gnu99 -Isrc/lib/lua -Iinclude
|
||||||
|
|
||||||
BUILD = bin/
|
BUILD = bin/
|
||||||
SOURCE = src/c/
|
SOURCE = src/c/
|
||||||
@ -22,14 +26,9 @@ OBJECTS := $(patsubst $(SOURCE)%.c, $(BUILD)%.c.o, $(CFILES))
|
|||||||
$(BUILDDIRECTORIES):
|
$(BUILDDIRECTORIES):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
#Clean
|
|
||||||
|
|
||||||
#Build
|
#Build
|
||||||
all: smallclean $(BUILDDIRECTORIES) luaresources $(BUILD)lupi
|
all: smallclean $(BUILDDIRECTORIES) luaresources $(BUILD)lupi
|
||||||
|
|
||||||
smallclean:
|
|
||||||
find . -name '*~' -type f -exec rm {} \;
|
|
||||||
|
|
||||||
build: clean all
|
build: clean all
|
||||||
|
|
||||||
$(BUILD)lupi: $(OBJECTS)
|
$(BUILD)lupi: $(OBJECTS)
|
||||||
@ -51,3 +50,10 @@ cleanresourcues:
|
|||||||
|
|
||||||
clean: cleanresourcues
|
clean: cleanresourcues
|
||||||
-rm -rf $(BUILD)
|
-rm -rf $(BUILD)
|
||||||
|
|
||||||
|
smallclean:
|
||||||
|
find . -name '*~' -type f -exec rm {} \;
|
||||||
|
|
||||||
|
# Other
|
||||||
|
|
||||||
|
.PHONY: clean cleanresourcues luaresources build smallclean all
|
@ -157,4 +157,8 @@ function api.totalMemory()
|
|||||||
return native.totalMemory()
|
return native.totalMemory()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function api.shutdown()
|
||||||
|
os.exit(0)
|
||||||
|
end
|
||||||
|
|
||||||
return computer
|
return computer
|
@ -17,6 +17,7 @@ io.write = function(...)
|
|||||||
io.flush()
|
io.flush()
|
||||||
native.sleep(20000)
|
native.sleep(20000)
|
||||||
end]]--
|
end]]--
|
||||||
|
|
||||||
local write = io.write
|
local write = io.write
|
||||||
local flush = io.flush
|
local flush = io.flush
|
||||||
|
|
||||||
|
@ -20,14 +20,14 @@ All rights reserved.
|
|||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
this list of conditions and the following disclaimer.
|
this list of conditions and the following disclaimer.
|
||||||
* Redistributions in binary form must reproduce the above copyright
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
* Neither the name of the author nor the names of its contributors may be
|
* Neither the name of the author nor the names of its contributors may be
|
||||||
used to endorse or promote products derived from this software without
|
used to endorse or promote products derived from this software without
|
||||||
specific prior written permission.
|
specific prior written permission.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
@ -55,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
--
|
--
|
||||||
|
|
||||||
local strbyte, strlen, strsub, type = string.byte, string.len, string.sub, type
|
local strbyte, strlen, strsub, type = string.byte, string.len, string.sub, type
|
||||||
|
local lutf8 = utf8
|
||||||
local utf8 = {}
|
local utf8 = {}
|
||||||
|
|
||||||
-- returns the number of bytes used by the UTF-8 character at byte i in s
|
-- returns the number of bytes used by the UTF-8 character at byte i in s
|
||||||
@ -230,7 +231,27 @@ local function utf8sub(s, i, j)
|
|||||||
return strsub(s, startByte, endByte)
|
return strsub(s, startByte, endByte)
|
||||||
end
|
end
|
||||||
|
|
||||||
utf8.sub = utf8sub
|
function utf8.sub(s,i,j)
|
||||||
|
i = i or 1
|
||||||
|
j = j or math.maxinteger
|
||||||
|
if i<1 or j<1 then
|
||||||
|
local n = lutf8.len(s)
|
||||||
|
if not n then return nil end
|
||||||
|
if i<0 then i = n+1+i end
|
||||||
|
if j<0 then j = n+1+j end
|
||||||
|
if i<0 then i = 1 elseif i>n then i = n end
|
||||||
|
if j<0 then j = 1 elseif j>n then j = n end
|
||||||
|
end
|
||||||
|
if j<i then return "" end
|
||||||
|
i = lutf8.offset(s,i) or math.maxinteger
|
||||||
|
j = lutf8.offset(s,j+1) or math.maxinteger
|
||||||
|
if i and j then return s:sub(i,j-1)
|
||||||
|
elseif i then return s:sub(i)
|
||||||
|
else return ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--utf8.sub = utf8sub
|
||||||
|
|
||||||
-- replace UTF-8 characters based on a mapping table
|
-- replace UTF-8 characters based on a mapping table
|
||||||
local function utf8replace(s, mapping)
|
local function utf8replace(s, mapping)
|
||||||
|
Loading…
Reference in New Issue
Block a user