Thread: [Codestriker-commits] CVS update: codestriker/lib/Codestriker/Http Render.pm
Brought to you by:
sits
|
From: <si...@us...> - 2006-06-13 23:38:42
|
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 <pat...@ma...>.
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 ed....@si....
+* Improved memory usage when integrated with very large LXR databases.
+ Contributed by Patrick Diamond <pat...@ma...>.
+
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 {
|
|
From: <si...@us...> - 2008-02-26 08:32:20
|
User: sits
Date: 08/02/26 00:32:18
Modified: . CHANGELOG
lib/Codestriker/Http Render.pm
Log:
* Make sure very long filenames don't move the diff display far to the
right of the view topic page. Fix suggested by
rob...@us....
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -r1.224 -r1.225
--- CHANGELOG 21 Feb 2008 02:32:09 -0000 1.224
+++ CHANGELOG 26 Feb 2008 08:32:17 -0000 1.225
@@ -27,6 +27,10 @@
* Make sure if an invalid CGI parameter value is specified that its
value is encoded when displaying the generic error page. Reported
by ama...@us....
+
+* Make sure very long filenames don't move the diff display far to the
+ right of the view topic page. Fix suggested by
+ rob...@us....
Version 1.9.4
Index: Render.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Render.pm,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- Render.pm 13 Jun 2006 23:38:40 -0000 1.53
+++ Render.pm 26 Feb 2008 08:32:17 -0000 1.54
@@ -413,43 +413,48 @@
if ($file_url eq "") {
# Output the header without hyperlinking the filename.
- $cell = $query->td({-class=>'file', -colspan=>'3'},
- "Diff for ",
- $query->a({name=>$filename},
- $filename),
- $revision_text);
+ $cell = "Diff for " .
+ $query->a({name=>$filename},
+ $filename) .
+ $revision_text;
}
else {
# Link the filename to the repository system with more information
# about it.
- $cell = $query->td({-class=>'file', -colspan=>'3'},
- "Diff for ",
- $query->a({href=>$file_url,
- name=>$filename},
- $filename),
- $revision_text);
+ $cell = "Diff for " .
+ $query->a({href=>$file_url,
+ name=>$filename},
+ $filename) .
+ $revision_text;
}
# Output the "back to contents" link and some browsing links
# for visiting the previous and next file (<<, >>), in
# addition to the "add file-level comment" link.
- print $query->Tr($cell, # = file header
- $query->td({-class=>'file', align=>'right'},
- "$add_file_level_comment_text ",
- ($bwd_url ne "" ? $query->a({href=>$bwd_url},"[<<]") : ""),
- $query->a({href=>$contents_url},"[Top]"),
- ($fwd_url ne "" ? $query->a({href=>$fwd_url},"[>>]") : "")));
+ print $query->Tr($query->td({-class=>'file', -colspan=>'4'},
+ $query->table({-width=>'100%'},
+ $query->Tr(
+ $query->td({align=>'left'}, $cell),
+ $query->td({align=>'right'},
+ "$add_file_level_comment_text ",
+ ($bwd_url ne "" ? $query->a({href=>$bwd_url},"[<<]") : ""),
+ $query->a({href=>$contents_url},"[Top]"),
+ ($fwd_url ne "" ? $query->a({href=>$fwd_url},"[>>]") : ""))))));
} else {
# No match in repository, or a new file.
- print $query->Tr($query->td({-class=>'file', -colspan=>'3'},
- "File ",
- $query->a({name=>$filename},$filename)),
- $query->td({-class=>'file', align=>'right'},
- "$add_file_level_comment_text ",
- ($bwd_url ne "" ? $query->a({href=>$bwd_url},"[<<]") : ""),
- $query->a({href=>$contents_url},"[Top]"),
- ($fwd_url ne "" ? $query->a({href=>$fwd_url},"[>>]") : "")));
+ print $query->Tr($query->td({-class=>'file', -colspan=>'4'},
+ $query->table({-width=>'100%'},
+ $query->Tr(
+ $query->td({align=>'left'},
+ "File ",
+ $query->a({name=>$filename},
+ $filename)),
+ $query->td({align=>'right'},
+ "$add_file_level_comment_text ",
+ ($bwd_url ne "" ? $query->a({href=>$bwd_url},"[<<]") : ""),
+ $query->a({href=>$contents_url},"[Top]"),
+ ($fwd_url ne "" ? $query->a({href=>$fwd_url},"[>>]") : ""))))));
}
}
|