local seq = { 1, 2, 3, 4, 5 } -- obviously, it's a sequence.
local non_seq = { 1, 2, 3, nil, 5 } -- but it's not.
Run Code Online (Sandbox Code Playgroud)
序列的定义:长度运算符
这个问题在《Programming in Lua 4st》第五章中。
如有任何意见,我将不胜感激
我正在分析一段低效的代码,但其中有些代码是如此令人困惑?
原始代码:
#include <string.h>
void lowwer(char *str) {
for (int i = 0; i < strlen(str); ++i) {
str[i] -= ('A' - 'a');
}
}
Run Code Online (Sandbox Code Playgroud)
汇编代码(由 clang 13 使用 -Og 选项生成):
lowwer:
pushq %r14 # use saved-registers
pushq %rbx
pushq %rax
# guard do while
cmpb $0, (%rdi) # compare &str with null (check if strlen(str) == 0)
je .LBB0_3
# loop initialization
movq %rdi, %r14 # %r14 = str
xorl %ebx, %ebx # clear %rbx (for more compact encoding) …Run Code Online (Sandbox Code Playgroud)