Unanswered
What is the more gas efficient for this 2 type of code in FunC?
Case 1:
() recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure {
slice cs = in_msg_full.begin_parse();
int flags = cs~load_uint(4);
if ((flags & 1) | (in_msg_body.slice_empty?())) {
return ();
}
slice sender = cs~load_msg_addr();
int op = in_msg_body~load_uint(32);
;; (int op, int query_id) = (in_msg_body~load_uint(32), in_msg_body~load_uint(64));
if (op == op::claim) {
query_id = in_msg_body~load_uint(64);
;; .....code..... ;;
}
elseif (op == op::process_claim) {
query_id = in_msg_body~load_uint(64);
;; .....code..... ;;
}
}
Case2:
() recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure {
slice cs = in_msg_full.begin_parse();
int flags = cs~load_uint(4);
if ((flags & 1) | (in_msg_body.slice_empty?())) {
return ();
}
slice sender = cs~load_msg_addr();
;; int op = in_msg_body~load_uint(32);
(int op, int query_id) = (in_msg_body~load_uint(32), in_msg_body~load_uint(64));
if (op == op::claim) {
;; query_id = in_msg_body~load_uint(64);
;; .....code..... ;;
}
elseif (op == op::process_claim) {
;; query_id = in_msg_body~load_uint(64);
;; .....code..... ;;
}
}
As you can see, the difference is only calling the query_id = in_msg_body~load_uint(64)
firstly or inside the if
method. Should we notice the gas efficient at this moment?
4K Views
0
Answers
one year ago
one year ago
Tags