mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 02:32:44 +03:00
Use a hash as the skiplist key
This commit is contained in:
parent
4c2d40b35e
commit
af71481a5f
@ -76,7 +76,7 @@ S_AMIGA := gui.c tree.c history.c hotlist.c schedule.c file.c \
|
||||
datatypes.c dt_picture.c dt_anim.c dt_sound.c plugin_hack.c \
|
||||
stringview/stringview.c stringview/urlhistory.c rtg.c \
|
||||
agclass/amigaguide_class.c os3support.c font_bitmap.c \
|
||||
selectmenu.c
|
||||
selectmenu.c fnv/hash_32a.c
|
||||
S_AMIGA := $(addprefix amiga/,$(S_AMIGA))
|
||||
|
||||
# This is the final source build list
|
||||
|
@ -77,6 +77,7 @@
|
||||
#define __FNV_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define FNV_VERSION "5.0.2" /* @(#) FNV Version */
|
||||
|
||||
@ -84,7 +85,7 @@
|
||||
/*
|
||||
* 32 bit FNV-0 hash type
|
||||
*/
|
||||
typedef u_int32_t Fnv32_t;
|
||||
typedef uint32_t Fnv32_t;
|
||||
|
||||
|
||||
/*
|
||||
@ -115,7 +116,7 @@ typedef u_int32_t Fnv32_t;
|
||||
/*
|
||||
* determine how 64 bit unsigned values are represented
|
||||
*/
|
||||
#include "longlong.h"
|
||||
//#include "longlong.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -125,7 +126,7 @@ typedef u_int32_t Fnv32_t;
|
||||
typedef u_int64_t Fnv64_t;
|
||||
#else /* HAVE_64BIT_LONG_LONG */
|
||||
typedef struct {
|
||||
u_int32_t w32[2]; /* w32[0] is low order, w32[1] is high order word */
|
||||
uint32_t w32[2]; /* w32[0] is low order, w32[1] is high order word */
|
||||
} Fnv64_t;
|
||||
#endif /* HAVE_64BIT_LONG_LONG */
|
||||
|
||||
|
25
amiga/font.c
25
amiga/font.c
@ -52,6 +52,9 @@
|
||||
#include "amiga/utf8.h"
|
||||
#include "amiga/object.h"
|
||||
#include "amiga/schedule.h"
|
||||
#ifdef __amigaos4__
|
||||
#include <amiga/fnv/fnv.h>
|
||||
#endif
|
||||
|
||||
#define NSA_UNICODE_FONT PLOT_FONT_FAMILY_COUNT
|
||||
|
||||
@ -373,8 +376,10 @@ static struct ami_font_node *ami_font_open(const char *font, bool critical)
|
||||
struct ami_font_node *nodedata = NULL;
|
||||
|
||||
#ifdef __amigaos4__
|
||||
nodedata = (struct ami_font_node *)FindSkipNode(ami_font_list, (APTR)font);
|
||||
Fnv32_t hash = fnv_32a_str(font, FNV1_32A_INIT);
|
||||
nodedata = (struct ami_font_node *)FindSkipNode(ami_font_list, (APTR)hash);
|
||||
#else
|
||||
int hash = 0;
|
||||
struct nsObject *node = (struct nsObject *)FindIName((struct List *)ami_font_list, font);
|
||||
if(node) nodedata = node->objstruct;
|
||||
#endif
|
||||
@ -384,10 +389,10 @@ static struct ami_font_node *ami_font_open(const char *font, bool critical)
|
||||
return nodedata;
|
||||
}
|
||||
|
||||
LOG("Font cache miss: %s", font);
|
||||
LOG("Font cache miss: %s (%lx)", font, hash);
|
||||
|
||||
#ifdef __amigaos4__
|
||||
nodedata = (struct ami_font_node *)InsertSkipNode(ami_font_list, (APTR)font, sizeof(struct ami_font_node));
|
||||
nodedata = (struct ami_font_node *)InsertSkipNode(ami_font_list, (APTR)hash, sizeof(struct ami_font_node));
|
||||
#else
|
||||
nodedata = AllocVecTagList(sizeof(struct ami_font_node), NULL);
|
||||
#endif
|
||||
@ -916,7 +921,9 @@ void ami_font_savescanner(void)
|
||||
#ifdef __amigaos4__
|
||||
static LONG ami_font_cache_sort(struct Hook *hook, APTR key1, APTR key2)
|
||||
{
|
||||
return stricmp(key1, key2);
|
||||
if(key1 == key2) return 0;
|
||||
if(key1 < key2) return -1;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -936,7 +943,7 @@ static void ami_font_cleanup(struct SkipList *skiplist)
|
||||
SubTime(&curtime, &node->lastused);
|
||||
if(curtime.Seconds > 300)
|
||||
{
|
||||
LOG("Freeing %s not used for %ld seconds", node->skip_node.sn_Key, curtime.Seconds);
|
||||
LOG("Freeing %ld not used for %ld seconds", node->skip_node.sn_Key, curtime.Seconds);
|
||||
ami_font_close(node);
|
||||
RemoveSkipNode(skiplist, node->skip_node.sn_Key);
|
||||
}
|
||||
@ -998,15 +1005,15 @@ void ami_init_fonts(void)
|
||||
#ifdef __amigaos4__
|
||||
static void ami_font_del_skiplist(struct SkipList *skiplist)
|
||||
{
|
||||
struct SkipNode *node;
|
||||
struct ami_font_node *node;
|
||||
struct SkipNode *nnode;
|
||||
|
||||
node = GetFirstSkipNode(skiplist);
|
||||
node = (struct ami_font_node *)GetFirstSkipNode(skiplist);
|
||||
if(node == NULL) return;
|
||||
|
||||
do {
|
||||
nnode = GetNextSkipNode(skiplist, node);
|
||||
ami_font_close((struct ami_font_node *)node);
|
||||
nnode = GetNextSkipNode(skiplist, (struct SkipNode *)node);
|
||||
ami_font_close(node);
|
||||
|
||||
} while((node = nnode));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user