Second Lifeで気に入ったアイテムの記録です あ、ウソです。スクリプトとか他のことも書いてます

2008/12/21

昨日のコードのこと

昨日のコードですけど、dataserverまわりって
これでいいですよね。

一度書いて、うまくいったコードって
なかなか振り返ることもなかったので
全く気づいてなかったです。
いま、割とメモリを気にする処理を書いてて
いろいろ見直してて気づきました。


dataserver(key query_id, string data){
if (query_id == key_ReadQ){
if (data == EOF)
state idle;

f_Analysis_note(data);
}else if (query_id == key_GetLineNumQ){
gl_i_loop_max = (integer)data;
if (gl_i_loop_max<=0){
llOwnerSay(gl_s_notecard+" is line Zero");
state idle;
}
}
key_ReadQ = llGetNotecardLine(gl_s_notecard, gl_i_loop_cnt);
++gl_i_loop_cnt;
llSetText("Read Note["+gl_s_notecard+"]"
+"\n("+(string)(gl_i_loop_cnt)+"/"+(string)(gl_i_loop_max)+")"
,GL_V_TEXT,1.0);
}


この2行は
key_ReadQ = llGetNotecardLine(gl_s_notecard, gl_i_loop_cnt);
++gl_i_loop_cnt;

当然、こう書いてもいいです。
key_ReadQ = llGetNotecardLine(gl_s_notecard, gl_i_loop_cnt++);

また、これは
gl_i_loop_max = (integer)data;
if (gl_i_loop_max<=0){

これでもいいですね
if ((gl_i_loop_max = (integer)data)<=0){

0 コメント: