joes        2004/07/23 00:21:15

  Modified:    .        STATUS
               glue/perl/t/response/TestApReq request.pm
               glue/perl/xsbuilder apreq_xs_tables.h
               glue/perl/xsbuilder/Apache/Upload Apache__Upload.h
  Log:
  Drop MAGIC KEYS.  They turn out to slow things down a little, and the fact 
that their magic survives assignment is a bad thing- users could assign a key 
to a global variable that is used in many different requests.  The magic 
pointer is corrupt once the current request pool cleans it up, so only bad 
things can happen after that.  There seems to be no upside to MAGIC KEYS now 
that APR::Table handles multivalued keys correctly, so that experiment dies 
here.
  
  Revision  Changes    Path
  1.76      +1 -18     httpd-apreq-2/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/STATUS,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- STATUS    23 Jul 2004 06:36:35 -0000      1.75
  +++ STATUS    23 Jul 2004 07:21:14 -0000      1.76
  @@ -94,23 +94,6 @@
       - Should we bundle an apr-based "application/xml" parser?  
         If so, how should we parse the xml data into an apr_table?
   
  -    - For 5.8.1+, the current perl-glue implementation enables 
  -      MAGIC KEYS for all the @keys = $obj->get() calls.  The entries 
  -      in @keys are scalars with vstring-magic which is survives
  -      assignment.  The magic contains a pointer to the perl object
  -      $obj references, and a pointer to the table value associated
  -      with the key. A subsequent call to $val = $obj->get($key[$n])
  -      bypasses the normal table lookups, using the magic in $key[$n] 
  -      to retrieve $val.
  -      .
  -      I don't know if the faster lookups balance out the overhead
  -      of attaching the v-string magic, so it's something that probably
  -      should be benchmarked.  However the real motivation for this
  -      was to provide better support for multivalued keys (since a
  -      magic key "knows" which value it's associated with).  Whether
  -      or not users will appreciate this feature, or find it too confusing,
  -      is presently unknown.
  -
   
   BUGS:
   
  
  
  
  1.35      +0 -14     httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm
  
  Index: request.pm
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- request.pm        23 Jul 2004 06:36:35 -0000      1.34
  +++ request.pm        23 Jul 2004 07:21:14 -0000      1.35
  @@ -179,20 +179,6 @@
                       $test_string eq "test:disable_uploads:foo:bar1:foo:bar2";
               }
   
  -            # MAGIC KEY TESTS
  -            if ($^V ge v5.8.1) {
  -                warn "Running MAGIC KEY tests";
  -                $test_string = "";
  -                $test_string .= "$_=" . $args->get($_) . ";" for $args->get;
  -                die "get test failed: '$test_string'" unless
  -                    $test_string eq 
"test=disable_uploads;foo=bar1;foo=bar2;";
  -
  -                $test_string = "";
  -                $test_string .= "$_=" . $args->get($_) . ";" for @_ = 
$args->get;
  -                die "get test2 failed: '$test_string'" unless
  -                    $test_string eq 
"test=disable_uploads;foo=bar1;foo=bar2;";
  -            }
  -
               # TABLE DO TESTS
               {
                   my $do_data = "";
  
  
  
  1.28      +0 -36     httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_tables.h
  
  Index: apreq_xs_tables.h
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/xsbuilder/apreq_xs_tables.h,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- apreq_xs_tables.h 22 Jul 2004 03:29:08 -0000      1.27
  +++ apreq_xs_tables.h 23 Jul 2004 07:21:14 -0000      1.28
  @@ -158,25 +158,6 @@
   }
   
   
  -/* KEY MAGIC: needs 5.8.x, x >= 1 (not sure if this will work in 5.10.x) */
  -
  -#if (PERL_VERSION == 8 && PERL_SUBVERSION >= 1)
  -
  -#define APREQ_XS_TABLE_ADD_KEY_MAGIC(p, sv, o, v) do {                  \
  -    struct apreq_xs_table_key_magic *info = apr_palloc(p,sizeof *info); \
  -    info->obj = o;                                                      \
  -    info->val = v;                                                      \
  -    sv_magic(sv, Nullsv, PERL_MAGIC_vstring, (char *)info, -1);         \
  -    SvRMAGICAL_on(sv);                                                  \
  -} while (0)
  -
  -#else
  -
  -#define APREQ_XS_TABLE_ADD_KEY_MAGIC(p,sv,o,v) /* noop */
  -
  -#endif
  -
  -
   /* TABLE_GET */
   struct apreq_xs_table_key_magic {
       SV         *obj;
  @@ -201,7 +182,6 @@
   
       dSP;
       SV *sv = newSVpv(key,0);
  -    APREQ_XS_TABLE_ADD_KEY_MAGIC(apreq_env_pool(d->env),sv,d->parent,val);
       XPUSHs(sv_2mortal(sv));
       PUTBACK;
       return 1;
  @@ -293,22 +273,6 @@
                   
XPUSHs(sv_2mortal(apreq_xs_table2sv(t,class,d.parent,d.pkg))); \
               PUTBACK;                                                    \
               break;                                                      \
  -        }                                                               \
  -        if (SvMAGICAL(ST(1))                                            \
  -            && (mg = mg_find(ST(1),PERL_MAGIC_vstring))                 \
  -            && mg->mg_len == -1 /*&& mg->mg_obj == obj*/)               \
  -        {                                                               \
  -            struct apreq_xs_table_key_magic *info = (void*)mg->mg_ptr;  \
  -            if (info->obj == d.parent) {                                \
  -                RETVAL = apreq_value_to_##type(                         \
  -                                       apreq_strtoval(info->val));      \
  -                if (!strcasecmp(key,RETVAL->v.name) && (COND)) {        \
  -                        XPUSHs(sv_2mortal(apreq_xs_##type##2sv(         \
  -                                              RETVAL,d.pkg,d.parent))); \
  -                        PUTBACK;                                        \
  -                        break;                                          \
  -                }                                                       \
  -            }                                                           \
           }                                                               \
                                                                           \
           RETVAL = apreq_xs_##attr##_##type(obj, key);                    \
  
  
  
  1.28      +0 -1      
httpd-apreq-2/glue/perl/xsbuilder/Apache/Upload/Apache__Upload.h
  
  Index: Apache__Upload.h
  ===================================================================
  RCS file: 
/home/cvs/httpd-apreq-2/glue/perl/xsbuilder/Apache/Upload/Apache__Upload.h,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Apache__Upload.h  22 Jul 2004 03:29:09 -0000      1.27
  +++ Apache__Upload.h  23 Jul 2004 07:21:15 -0000      1.28
  @@ -93,7 +93,6 @@
           return 1;
   
       sv = newSVpv(key,0);
  -    APREQ_XS_TABLE_ADD_KEY_MAGIC(apreq_env_pool(d->env),sv,d->parent,val);
       XPUSHs(sv_2mortal(sv));
       PUTBACK;
       return 1;
  
  
  

Reply via email to