Re: Patch to fix #314139 [REVISION PROPOSAL]



On Fri, 2006-06-16 at 10:39 +0300, Sivan Greenberg wrote:
> On Thu, 2006-06-15 at 09:32 +0200, Alexander Larsson wrote:
> > your function call and its arguments, and then compare the stored values
> > first in the function.
> 
> Alex, re caching implementation , I have a top level sketch in mind,
> would like to hear your opinion:
> 
> 1) The cache encapsulating function will be called something like
> "cached_uri_info".
> 2) First time the function is called, there will be ofcourse no caching.
> called params and results will be queued.
> 
> 
> Now, I figured I would better have something that would act like a
> cyclic queue, e.g. overwriting old values each time a cycle is
> completed.
> 
> Now how long back should values be cached ? Should it go back as long as
> memory allows?

Nah, this sounds way to complicated. You just save *one* value for the
last check, and save it for the drag operation.

Something like:
struct MoveConvertCache {
	char *source_uri;
	char *target_uri;
	gboolean res;
}

static gboolean 
should_convert_move_to_copy (GdkDragContext *context,
			     const char *source_uri,
			     const char *target_uri)
{
  struct MoveConvertCache *cache;
  gboolean res;
  
  cache = g_object_get_data (context, "move-convert-cache");
  if (cache != NULL &&
      strcmp(cache->source_uri, source_uri) == 0 &&
      strcmp(cache->target_uri, target_uri) == 0) {
    return cache->res;
  }

  res = ...;

  cache = g_new (struct MoveConvertCache, 1);
  cache->res = res;
  cache->source_uri = g_strdup (source_uri);
  cache->target_uri = g_strdup (target_uri);
  g_object_set_data_full (context, "move-convert-cache",
			  cache, free_move_convert_cache);
  
  return res;
}

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a one-legged shark-wrestling barbarian fleeing from a secret government 
programme. She's a hard-bitten extravagent college professor who believes she 
is the reincarnation of an ancient Egyptian queen. They fight crime! 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]