Author Topic: Dfn_var_type?  (Read 172 times)

0 Members and 1 Guest are viewing this topic.

d2010

  • Bull Frog
  • Posts: 284
Dfn_var_type?
« on: May 22, 2022, 03:17:52 AM »
The subject=
"Change type-of-variabile("ent_list"), You do  slow-down of speed too much?"
Hello..............
 :police:=In other/s programmingLanguages ,if exists "change too many types of variabiles(not value)", you slow down of speed too much.(e.g php_array to integer).

 :glarestraight:=Anyone can benchmark of speed "change variabile types?".
You can test any variabile type.

(Defun ent_makeText(pnt rotation / ent_list)
(setq ent_list(list
   (cons 50 rotation)
    (list 11 (car pnt) (cadr pnt) 0.0)
    ) ;_ end of list
  ) ;_ end of setq
  (setq ent_list (entmakex ent_list))
)
Code - Auto/Visual Lisp: [Select]
  1. (Defun dfn_var_type (v391 / ret a)
  2. /*c2s:
  3.        a=type(v391);
  4.        ret=cond(a==quote(INT) ,1 ;
  5.               a==quote(STR) ,2 ;
  6.               a==quote(SYM) ,3 ;
  7.               a==quote(REAL),4 ;
  8.            a==quote(PICKSET),5 ;
  9.              a==quote(ENAME),6 ;
  10.               a==quote(SUBR),7 ;
  11.               a==quote(LIST),8 ;
  12.               a==nil,9;
  13.               a==quote(USUBR),10;
  14.               a==quote(EXRXSUBR),11;
  15.               atom("$ v391"),12;
  16.               0);
  17. */
  18. ret)
  19.  
« Last Edit: May 22, 2022, 03:43:58 AM by d2010 »

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7320
  • AKA Daniel
Re: Dfn_var_type?
« Reply #1 on: May 22, 2022, 04:02:47 AM »
Changing the type is, allocating new and destroying old memory.
Either way, it can be expensive computationally, but this shouldn’t be a real concern unless you’re dealing with millions of objects
Retired

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7320
  • AKA Daniel
Re: Dfn_var_type?
« Reply #2 on: May 22, 2022, 04:15:18 AM »
Actually, what I said is not quite true. at least from an ARX perspective.
ads_u_val is a union that holds 192bits ...?....
So, in theory, if the item fits in the memory space, new memory may not be allocated.
I.e changing and int to a point won't require new memory allocation. changing and int to a string would be expensive
Retired