aboutsummaryrefslogtreecommitdiff
path: root/src/dicache.c
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2009-01-05 09:38:42 -0300
committerJorge Arellano Cid <jcid@dillo.org>2009-01-05 09:38:42 -0300
commite705debdae8d2ff8e4331246e4d51c077a4235ba (patch)
tree78a509aaad8bf3cfc65a58b5fa4f3df4e1412b28 /src/dicache.c
parentf5decdf48e13d89f133c27e9e8b77c5e04aa4bbd (diff)
These optimizations are for repeated images in a page.
1.- Every repeated cache-served-image is decoded. The patch adds an extra reference to the dicache entry, so only one of them is decoded, and the imgbuf deletion is left to a_Dicache_cleanup. 2.- Every repeated cache-served-image call copyRow for each row. The patch avoids that. This is common with small images (e.g. bullets), but the overhead may be not worth the patch...
Diffstat (limited to 'src/dicache.c')
-rw-r--r--src/dicache.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/dicache.c b/src/dicache.c
index c8cf7471..975b6a10 100644
--- a/src/dicache.c
+++ b/src/dicache.c
@@ -388,10 +388,12 @@ void a_Dicache_callback(int Op, CacheClient_t *Client)
Client->Version = DicEntry->version;
/* Only call the decoder when necessary */
+ int newData = FALSE;
if (Op == CA_Send && DicEntry->State < DIC_Close &&
DicEntry->DecodedSize < Client->BufSize) {
DicEntry->Decoder(Op, Client);
DicEntry->DecodedSize = Client->BufSize;
+ newData = TRUE;
} else if (Op == CA_Close || Op == CA_Abort) {
if (DicEntry->State < DIC_Close) {
DicEntry->Decoder(Op, Client);
@@ -409,7 +411,7 @@ void a_Dicache_callback(int Op, CacheClient_t *Client)
DicEntry->version, DicEntry->width, DicEntry->height,
DicEntry->type);
}
- if (DicEntry->State == DIC_Write) {
+ if (DicEntry->State == DIC_Write && newData) {
if (DicEntry->ScanNumber == Image->ScanNumber) {
for (i = 0; i < DicEntry->height; ++i)
if (a_Bitvec_get_bit(DicEntry->BitVec, (int)i) &&
@@ -450,8 +452,8 @@ void a_Dicache_cleanup(void)
node = dList_nth_data(CachedIMGs, i);
/* iterate each entry of this node */
for (entry = node->first; entry; entry = entry->next) {
- if (entry->v_imgbuf &&
- a_Imgbuf_last_reference(entry->v_imgbuf)) {
+ if (entry->RefCount == 1 ||
+ (entry->v_imgbuf && a_Imgbuf_last_reference(entry->v_imgbuf))) {
/* free this unused entry */
if (entry->next) {
Dicache_remove(node->url, entry->version);