Thank you so very much Lee,

I'm still a little foggy on the whole C_Object concept but regardless of that 
limitation on my part your example was exactly what I needed to get me started.

It is AMAZING!

I did some exaggerated stress testing and it seemed to be 100 to as much as 
1,000 times as fast as using find in array!  That performance was more than 
quick enough to allow me to use this implementation. The worst case is that it 
adds a millisecond or so to each interaction.

Because of that, in brief, I simply copied my variables from compiler_variables 
and pasted them into a new method and then did a global replace of all 
"C_Text("with APPEND TO ARRAY(<>arr_Defined_Text_Variables;".  I run the new 
method at startup and then execute the code below to build the object per your 
example.

Thank you again!

C_OBJECT(<>Obj_Defined_Text_Variables)
For ($i;1;Size of array(<>arr_Defined_Text_Variables))
        $VariableName:=<>arr_Defined_Text_Variables{$i}
        OB SET(<>Obj_Defined_Text_Variables;$VariableName;"")
End for
ARRAY TEXT(<>arr_Defined_Text_Variables;0)

-----Original Message-----
From: 4D_Tech [mailto:[email protected]] On Behalf Of Lee Hinde
Sent: Wednesday, November 9, 2016 1:26 PM
To: 4D iNug Tech <[email protected]>
Subject: Re: Automatic Variable Assignment and Web Get Variables - Bad usage of 
pointer or pointer to an unknown variable

C_OBJECT($temp)

For ($index;1;20000)

$key:="Variable_"+String($index)+"_name"

OB SET($temp;$key;"")
End for 

C_BOOLEAN($test)
C_LONGINT($start)
$start:=Milliseconds
$test:=OB Is defined($temp;"Variable_10000_name")
ALERT(String(Milliseconds-$start))  // I get 0

  //versus

ARRAY TEXT($temp_array;0)
C_LONGINT($fnd)

For ($index;1;20000)

$key:="Variable_"+String($index)+"_name"
APPEND TO ARRAY($temp_array;$key)
End for 

$start:=Milliseconds
$fnd:=Find in array($temp_array;"Variable_10000_name")
ALERT(String(Milliseconds-$start)) // I get 1

If I change the search parameter to Variable_20000_name, the array takes twice 
as long (2) and the c_object search is still 0.

This may or may not have been Justin’s point. :-)


> On Nov 9, 2016, at 1:03 PM, Mike McCall <[email protected]> wrote:
> 
> Thanks Lee,
> 
> Unfortunately, I'm not familiar with c_objects and how they might work in my 
> case. Would it be possible to give me a brief example that I could then adapt 
> and test.
> 
> Thanks again,
> 
> Mike
> 
> -----Original Message-----
> From: 4D_Tech [mailto:[email protected]] On Behalf Of Lee 
> Hinde
> Sent: Wednesday, November 9, 2016 12:59 PM
> To: 4D iNug Technical <[email protected]>
> Subject: Re: Automatic Variable Assignment and Web Get Variables - Bad 
> usage of pointer or pointer to an unknown variable
> 
> Justin Leavens did a summit presentation that showed c_objects were much 
> faster than arrays for searching. Might be worth a test.
> 
> On Wed, Nov 9, 2016 at 12:47 PM, Mike McCall 
> <[email protected]>
> wrote:
> 
>> Thanks so much Chip for the suggestion,
>> 
>> That thought also crossed my mind but unfortunately with the silly 
>> number of variables we currently have, over 20,000 in total, my 
>> initial tests suggested that it could seriously affect performance to 
>> go with that approach.
>> 
>> I'd really prefer not to have to do a complete rewrite of how we 
>> handle form fields since that would be very time consuming.
>> 
>> Thanks again and definitely let me know if you or anyone else has any 
>> other idea.
>> 
>> Mike
>> 
>> -----Original Message-----
>> From: 4D_Tech [mailto:[email protected]] On Behalf Of Chip 
>> Scheide
>> Sent: Wednesday, November 9, 2016 12:38 PM
>> To: 4D iNug Technical <[email protected]>
>> Subject: Re: Automatic Variable Assignment and Web Get Variables - 
>> Bad usage of pointer or pointer to an unknown variable
>> 
>> I do NO web work so take this idea with that in mind
>> 
>> Instead of :
>> On Wed, 9 Nov 2016 19:58:16 +0000, Mike McCall wrote:
>>>      Else
>>>                              $p:=Get pointer(arr_Web_Field_Name{$i})
>>>                              $p->:=arr_Web_Field_Value{$i}
>>>              End case
>> 
>> if (find in array($arr_Legal_Variable_Names;arr_Web_Field_Name{$i})>0)
>>   $p:=Get pointer(arr_Web_Field_Name{$i})
>>   $p->:=arr_Web_Field_Value{$i}
>> else
>>   `do nasty things since someone tried to hack your server end if
>> 
>> Where arr_Legal_Variable_Names
>> is an array of valid variable names and any value NOT in this array 
>> is an error Chip
>> 
>> 
> 

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to