随笔分类 -  Lua 学习笔记

摘要:= Things you should know about Lua's performance =This wiki is a result of some lua performance tests (the widget is included with ca sandbox).[[BR]][[BR]][[BR]]== TEST 1: localize ==Code:{{{#!lualocal min = math.min}}}Results:{{{#!html<div style="margin-left:25px"><font color 阅读全文
posted @ 2012-02-01 10:43 superchao 阅读(503) 评论(0) 推荐(0)
摘要:From:http://lua-users.org/wiki/LuaUnicodePattern MatchingLua's pattern matching facilities work character by character. In general, this will not work for Unicode pattern matching, although some things will work as you want. For example, "%u" will not match all Unicode upper case lette 阅读全文
posted @ 2011-09-22 20:42 superchao 阅读(1470) 评论(1) 推荐(0)
摘要:lua内存泄漏查证本文主要介绍某项目脚本(lua)部分内存泄漏的查证与处理过程,希望对大家有点帮助。需要说明的是,lua本身并不存在真正的内存泄漏,只是因为使用上面的原因导致无法gc,从而导致逻辑上的泄漏:)。 参考GCObject的声明可以发现,lua中的复杂数据类型变量的传递都是基于引用的。当lua从根开始gc扫描的时候,只要还有一个地方有对此变量的引用,那么这个变量就不会被collect。这种情况造成的危害取决于多大程度上依赖于引用,如果有适当的间接层/弱引用来隔离这个问题,可能问题会有所缓解。 以下是一些常见的错误引用情景: 1. 本应该local 的变量进入global空间或者mod 阅读全文
posted @ 2011-07-04 15:55 superchao 阅读(7098) 评论(1) 推荐(0)
摘要:LUA string库详解1. string库中所有的字符索引从前往后是1,2,...;从后往前是-1,-2,...2. string库中所有的function都不会直接操作字符串,而是返回一个结果s = "[abc]"string.len(s) <==返回5string.rep("abc", 2) <==返回"abcabc"string.lower("ABC") <==返回"abc"string.upper("abc") <==返回"ABC 阅读全文
posted @ 2011-06-20 10:23 superchao 阅读(63529) 评论(0) 推荐(3)
摘要:使用Lua自带的SciTE来编辑代码,有以下快捷健,官方原版是:Keyboard commandsKeyboard commands in SciTE mostly follow common Windows and GTK+ conventions. All movement keys (arrows, page up/down, home and end) allow to extend or reduce a stream selection when holding the Shift key, and a rectangular selection when holding the 阅读全文
posted @ 2011-06-15 17:38 superchao 阅读(3784) 评论(0) 推荐(0)