Commits

garfieldnate  committed 14e6790

Simplified unique_key implementation; now returns an integer.

  • Participants
  • Parent commits ce7af68

Comments (0)

Files changed (3)

 #include "xpath.h"
 #include "xpathcontext.h"
 
-/* unique_key stuff */
-#include "stdint.h"
-/*1 per bit in intptr_t, + 1 for trailing 0*/
-#define KEY_SIZE sizeof(intptr_t)+1
-
 #ifdef __cplusplus
 }
 #endif
     OUTPUT:
         RETVAL
 
-char*
+IV
 unique_key( self )
         xmlNodePtr self
     CODE:
-        /* Convert the node address into a hex string */
-        char hex_string[KEY_SIZE];
-        intptr_t address = (intptr_t) self;
-        sprintf(hex_string, "%0x", address);
-        hex_string[KEY_SIZE-1] = 0;
-        RETVAL = hex_string;
+        /* Cast pointer to IV */
+        RETVAL = PTR2IV(self);
     OUTPUT:
         RETVAL
 

File docs/libxml.dbk

 
                 <listitem>
                     <funcsynopsis>
-                        <funcsynopsisinfo>$string = $node-&gt;unique_key;</funcsynopsisinfo>
+                        <funcsynopsisinfo>$num = $node-&gt;unique_key;</funcsynopsisinfo>
                     </funcsynopsis>
 
                     <para>This function is not specified for any DOM level. It returns a key guaranteed to be unique for this node, and to always be the same value for this node. In other words, two node objects return the same key if and only if isSameNode indicates that they are the same node.</para>

File t/91unique_key.t

     for my $c2(0..4){
         if($c1 == $c2){
             # TEST*$num_children
-            ok($children_1[$c1]->unique_key eq $children_2[$c2]->unique_key,
+            ok($children_1[$c1]->unique_key == $children_2[$c2]->unique_key,
                 'Key for ' . $children_1[$c1]->nodeName .
                 ' matches key from same node');
         }else{
             # TEST*($num_children)*($num_children-1)
-            ok($children_1[$c1]->unique_key ne $children_2[$c2]->unique_key,
+            ok($children_1[$c1]->unique_key != $children_2[$c2]->unique_key,
                 'Key for ' . $children_1[$c1]->nodeName .
                 ' does not match key for' . $children_2[$c2]->nodeName);
         }