Commit a12117f0 authored by sasha@mysql.sashanet.com's avatar sasha@mysql.sashanet.com
Browse files

change tree to use qsort_cmp2 - compare function with 3 instead of 2 arguments

parent 15df552e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -349,6 +349,7 @@ typedef int pshort; /* Mixed prototypes can't take short int */
typedef double	pfloat;		/* Mixed prototypes can't take float */
#endif
typedef int	(*qsort_cmp)(const void *,const void *);
typedef int	(*qsort_cmp2)(void*, const void *,const void *);
#ifdef HAVE_mit_thread
#define qsort_t void
#undef QSORT_TYPE_IS_VOID
+3 −2
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ typedef struct st_tree {
  TREE_ELEMENT *root,null_element;
  TREE_ELEMENT **parents[MAX_TREE_HIGHT];
  uint offset_to_key,elements_in_tree,size_of_element;
  qsort_cmp compare;
  qsort_cmp2 compare;
  void* cmp_arg;
  MEM_ROOT mem_root;
  my_bool with_delete;
  void (*free)(void *);
@@ -58,7 +59,7 @@ typedef struct st_tree {

	/* Functions on hole tree */
void init_tree(TREE *tree,uint default_alloc_size, int element_size,
	       qsort_cmp compare, my_bool with_delete,
	       qsort_cmp2 compare, my_bool with_delete,
	       void (*free_element)(void*));
void delete_tree(TREE*);
#define is_tree_inited(tree) ((tree)->root != 0)
+2 −1
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ typedef struct st_ft_superdoc {
    ALL_IN_ONE *aio;
} FT_SUPERDOC;

static int FT_SUPERDOC_cmp(FT_SUPERDOC *p1, FT_SUPERDOC *p2)
static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)),
			   FT_SUPERDOC *p1, FT_SUPERDOC *p2)
{
  if (p1->doc.dpos < p2->doc.dpos)
    return -1;
+3 −2
Original line number Diff line number Diff line
@@ -35,7 +35,8 @@ typedef struct st_ft_superdoc {
    double   tmp_weight;
} FT_SUPERDOC;

static int FT_SUPERDOC_cmp(FT_SUPERDOC *p1, FT_SUPERDOC *p2)
static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)),
			   FT_SUPERDOC *p1, FT_SUPERDOC *p2)
{
  if (p1->doc.dpos < p2->doc.dpos)
    return -1;
@@ -162,7 +163,7 @@ FT_DOCLIST *ft_nlq_search(MI_INFO *info, uint keynr, byte *query,

  bzero(&allocated_wtree,sizeof(allocated_wtree));

  init_tree(&aio.dtree,0,sizeof(FT_SUPERDOC),(qsort_cmp)&FT_SUPERDOC_cmp,0,
  init_tree(&aio.dtree,0,sizeof(FT_SUPERDOC),(qsort_cmp2)&FT_SUPERDOC_cmp,0,
            NULL);

  if(!(wtree=ft_parse(&allocated_wtree,query,query_len)))
+3 −2
Original line number Diff line number Diff line
@@ -38,7 +38,8 @@ typedef struct st_ft_docstat {
  byte *keybuf;
} FT_DOCSTAT;

static int FT_WORD_cmp(FT_WORD *w1, FT_WORD *w2)
static int FT_WORD_cmp(void* cmp_arg __attribute__((unused)),
		       FT_WORD *w1, FT_WORD *w2)
{
  return _mi_compare_text(default_charset_info,
			  (uchar*) w1->pos,w1->len,
@@ -225,7 +226,7 @@ TREE * ft_parse(TREE *wtree, byte *doc, int doclen)

  if (!is_tree_inited(wtree))
  {
    init_tree(wtree,0,sizeof(FT_WORD),(qsort_cmp)&FT_WORD_cmp,0,NULL);
    init_tree(wtree,0,sizeof(FT_WORD),(qsort_cmp2)&FT_WORD_cmp,0,NULL);
  }

  while (ft_simple_get_word(&doc,end,&w))
Loading