User: sits    
  Date: 06/06/13 16:38:40

  Modified:    .        CHANGELOG
               lib/Codestriker/Http Render.pm
  Log:
  * Improved memory usage when integrated with very large LXR databases.
    Contributed by Patrick Diamond <[EMAIL PROTECTED]>.
  
  
  
  Index: CHANGELOG
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v
  retrieving revision 1.191
  retrieving revision 1.192
  diff -u -r1.191 -r1.192
  --- CHANGELOG 11 Jun 2006 08:29:11 -0000      1.191
  +++ CHANGELOG 13 Jun 2006 23:38:40 -0000      1.192
  @@ -89,6 +89,9 @@
     been removed if the topic is closed.
     Contributed by [EMAIL PROTECTED]
   
  +* Improved memory usage when integrated with very large LXR databases.
  +  Contributed by Patrick Diamond <[EMAIL PROTECTED]>.
  +
   Version 1.9.1
   
   * Correct problem introduced in 1.9.0 release where the email address
  
  
  
  
  
  Index: Render.pm
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Render.pm,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- Render.pm 1 Jul 2005 02:06:22 -0000       1.52
  +++ Render.pm 13 Jun 2006 23:38:40 -0000      1.53
  @@ -115,13 +115,12 @@
       $self->{diff_current_revision} = "";
       $self->{diff_current_repmatch} = 0;
   
  -    # Check if the repository has an associated LXR mapping, and if so, read
  -    # all the identifiers into a massive hashtable (gasp!).
  +    # Check if the repository has an associated LXR mapping, and if so, 
  +    # setup a db connection and prepare a select statement.
       if (defined $repository) {
        my $value = $Codestriker::lxr_map->{$repository->toString()};
        if (defined $value) {
            my %lxr = %{ $value };
  -         my %idhash = ();
   
            my $passwd = $lxr{password};
            if (! defined $passwd) {
  @@ -132,13 +131,10 @@
                                   {AutoCommit=>0, RaiseError=>1})
                || die "Couldn't connect to database: " . DBI->errstr;
            my $select_ids =
  -             $dbh->prepare_cached('SELECT symname FROM symbols');
  -         $select_ids->execute();
  -         while (my ($identifier) = $select_ids->fetchrow_array()) {
  -             $idhash{$identifier} = 1;
  -         }
  -         $dbh->disconnect;
  -         $self->{idhashref} = \%idhash;
  +             $dbh->prepare_cached('SELECT count(symname) FROM symbols where 
symname = ?');
  +         $self->{idhashref} = {};
  +         $self->{idhashsth} = $select_ids;
  +         $self->{idhashdbh} = $dbh;
            $self->{lxr_base_url} = $lxr{url};
        }
        else {
  @@ -151,10 +147,16 @@
        $self->{idhashref} = undef;
       }
   
  -
       bless $self, $type;
   }
   
  +# cleanup, disconnect from the lxr database if connected
  +sub DESTROY {
  +    my $self = shift;
  +    $self->{idhashdbh}->disconnect() if exists $self->{idhashdbh};
  +} 
  +
  +
   # Given an identifier, wrap it within the appropriate <A HREF> tag if it
   # is a known identifier to LXR, otherwise just return the id.  To avoid
   # excessive crap, only consider those identifiers which are at least 4
  @@ -163,8 +165,22 @@
       my ($self, $id) = @_;
   
       my $idhashref = $self->{idhashref};
  +    
  +    if (length($id) >= 4) {
  +     
  +     # Check if the id has not yet been found in lxr.
  +     if (not exists $idhashref->{$id}) {
  +         $idhashref->{$id} = 0;        # By default not found.
  +         my $sth = $self->{idhashsth}; # DB statement handle.
  +
  +         # Fetch ids from lxr and store in hash.
  +         $sth->execute($id);
  +         ($idhashref->{$id}) = $sth->fetchrow_array();
  +        }
  +    }
   
  -    if (length($id) >= 4 && defined $$idhashref{$id}) {
  +    # Check if the id has been found in lxr.
  +    if ($$idhashref{$id}) {
        return "<A HREF=\"" . $self->{lxr_base_url} . "$id\" " .
            "CLASS=\"fid\">$id</A>";
       } else {
  
  
  


_______________________________________________
Codestriker-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/codestriker-commits

Reply via email to