mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 08:22:16 +01:00 
			
		
		
		
	streamlined initialization code somewhat, removed GData node cache.
Wed Nov 23 13:35:31 2005 Tim Janik <timj@gtk.org> * glib/gdataset.c: streamlined initialization code somewhat, removed GData node cache.
This commit is contained in:
		| @@ -1,3 +1,8 @@ | |||||||
|  | Wed Nov 23 13:35:31 2005  Tim Janik  <timj@gtk.org> | ||||||
|  |  | ||||||
|  | 	* glib/gdataset.c: streamlined initialization code somewhat, | ||||||
|  | 	removed GData node cache. | ||||||
|  |  | ||||||
| 2005-11-22  Matthias Clasen  <mclasen@redhat.com> | 2005-11-22  Matthias Clasen  <mclasen@redhat.com> | ||||||
|  |  | ||||||
| 	* glib/ghash.c (g_hash_table_ref):  | 	* glib/ghash.c (g_hash_table_ref):  | ||||||
|   | |||||||
| @@ -1,3 +1,8 @@ | |||||||
|  | Wed Nov 23 13:35:31 2005  Tim Janik  <timj@gtk.org> | ||||||
|  |  | ||||||
|  | 	* glib/gdataset.c: streamlined initialization code somewhat, | ||||||
|  | 	removed GData node cache. | ||||||
|  |  | ||||||
| 2005-11-22  Matthias Clasen  <mclasen@redhat.com> | 2005-11-22  Matthias Clasen  <mclasen@redhat.com> | ||||||
|  |  | ||||||
| 	* glib/ghash.c (g_hash_table_ref):  | 	* glib/ghash.c (g_hash_table_ref):  | ||||||
|   | |||||||
| @@ -1,3 +1,8 @@ | |||||||
|  | Wed Nov 23 13:35:31 2005  Tim Janik  <timj@gtk.org> | ||||||
|  |  | ||||||
|  | 	* glib/gdataset.c: streamlined initialization code somewhat, | ||||||
|  | 	removed GData node cache. | ||||||
|  |  | ||||||
| 2005-11-22  Matthias Clasen  <mclasen@redhat.com> | 2005-11-22  Matthias Clasen  <mclasen@redhat.com> | ||||||
|  |  | ||||||
| 	* glib/ghash.c (g_hash_table_ref):  | 	* glib/ghash.c (g_hash_table_ref):  | ||||||
|   | |||||||
| @@ -41,7 +41,6 @@ | |||||||
|  |  | ||||||
| /* --- defines --- */ | /* --- defines --- */ | ||||||
| #define	G_QUARK_BLOCK_SIZE			(512) | #define	G_QUARK_BLOCK_SIZE			(512) | ||||||
| #define	G_DATA_CACHE_MAX			(512) |  | ||||||
|  |  | ||||||
| /* datalist pointer modifications have to be done with the g_dataset_global mutex held */ | /* datalist pointer modifications have to be done with the g_dataset_global mutex held */ | ||||||
| #define G_DATALIST_GET_POINTER(datalist)						\ | #define G_DATALIST_GET_POINTER(datalist)						\ | ||||||
| @@ -87,9 +86,6 @@ G_LOCK_DEFINE_STATIC (g_dataset_global); | |||||||
| static GHashTable   *g_dataset_location_ht = NULL; | static GHashTable   *g_dataset_location_ht = NULL; | ||||||
| static GDataset     *g_dataset_cached = NULL; /* should this be | static GDataset     *g_dataset_cached = NULL; /* should this be | ||||||
| 						 threadspecific? */ | 						 threadspecific? */ | ||||||
| static GData	    *g_data_cache = NULL; |  | ||||||
| static guint	     g_data_cache_length = 0; |  | ||||||
|  |  | ||||||
| G_LOCK_DEFINE_STATIC (g_quark_global); | G_LOCK_DEFINE_STATIC (g_quark_global); | ||||||
| static GHashTable   *g_quark_ht = NULL; | static GHashTable   *g_quark_ht = NULL; | ||||||
| static gchar       **g_quarks = NULL; | static gchar       **g_quarks = NULL; | ||||||
| @@ -122,13 +118,6 @@ g_datalist_clear_i (GData **datalist) | |||||||
| 	  G_LOCK (g_dataset_global); | 	  G_LOCK (g_dataset_global); | ||||||
| 	} | 	} | ||||||
|        |        | ||||||
|       if (g_data_cache_length < G_DATA_CACHE_MAX) |  | ||||||
| 	{ |  | ||||||
| 	  prev->next = g_data_cache; |  | ||||||
| 	  g_data_cache = prev; |  | ||||||
| 	  g_data_cache_length++; |  | ||||||
| 	} |  | ||||||
|       else |  | ||||||
|       g_slice_free (GData, prev); |       g_slice_free (GData, prev); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -253,13 +242,6 @@ g_data_set_internal (GData	  **datalist, | |||||||
| 	      else | 	      else | ||||||
| 		ret_data = list->data; | 		ret_data = list->data; | ||||||
| 	       | 	       | ||||||
| 	      if (g_data_cache_length < G_DATA_CACHE_MAX) |  | ||||||
| 		{ |  | ||||||
| 		  list->next = g_data_cache; |  | ||||||
| 		  g_data_cache = list; |  | ||||||
| 		  g_data_cache_length++; |  | ||||||
| 		} |  | ||||||
| 	      else |  | ||||||
|               g_slice_free (GData, list); |               g_slice_free (GData, list); | ||||||
| 	       | 	       | ||||||
| 	      return ret_data; | 	      return ret_data; | ||||||
| @@ -304,13 +286,6 @@ g_data_set_internal (GData	  **datalist, | |||||||
| 	  list = list->next; | 	  list = list->next; | ||||||
| 	} | 	} | ||||||
|        |        | ||||||
|       if (g_data_cache) |  | ||||||
| 	{ |  | ||||||
| 	  list = g_data_cache; |  | ||||||
| 	  g_data_cache = list->next; |  | ||||||
| 	  g_data_cache_length--; |  | ||||||
| 	} |  | ||||||
|       else |  | ||||||
|       list = g_slice_new (GData); |       list = g_slice_new (GData); | ||||||
|       list->next = G_DATALIST_GET_POINTER (datalist); |       list->next = G_DATALIST_GET_POINTER (datalist); | ||||||
|       list->id = key_id; |       list->id = key_id; | ||||||
| @@ -672,7 +647,7 @@ g_quark_to_string (GQuark quark) | |||||||
|   gchar* result = NULL; |   gchar* result = NULL; | ||||||
|  |  | ||||||
|   G_LOCK (g_quark_global); |   G_LOCK (g_quark_global); | ||||||
|   if (quark > 0 && quark <= g_quark_seq_id) |   if (quark < g_quark_seq_id) | ||||||
|     result = g_quarks[quark]; |     result = g_quarks[quark]; | ||||||
|   G_UNLOCK (g_quark_global); |   G_UNLOCK (g_quark_global); | ||||||
|  |  | ||||||
| @@ -687,15 +662,15 @@ g_quark_new (gchar *string) | |||||||
|    |    | ||||||
|   if (g_quark_seq_id % G_QUARK_BLOCK_SIZE == 0) |   if (g_quark_seq_id % G_QUARK_BLOCK_SIZE == 0) | ||||||
|     g_quarks = g_renew (gchar*, g_quarks, g_quark_seq_id + G_QUARK_BLOCK_SIZE); |     g_quarks = g_renew (gchar*, g_quarks, g_quark_seq_id + G_QUARK_BLOCK_SIZE); | ||||||
|    |  | ||||||
|   g_quarks[0] = NULL; |  | ||||||
|   g_quark_seq_id++; |  | ||||||
|   g_quarks[g_quark_seq_id] = string; |  | ||||||
|   quark = g_quark_seq_id; |  | ||||||
|  |  | ||||||
|   if (!g_quark_ht) |   if (!g_quark_ht) | ||||||
|  |     { | ||||||
|  |       g_assert (g_quark_seq_id == 0); | ||||||
|       g_quark_ht = g_hash_table_new (g_str_hash, g_str_equal); |       g_quark_ht = g_hash_table_new (g_str_hash, g_str_equal); | ||||||
|  |       g_quarks[g_quark_seq_id++] = NULL; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |   quark = g_quark_seq_id++; | ||||||
|  |   g_quarks[quark] = string; | ||||||
|   g_hash_table_insert (g_quark_ht, string, GUINT_TO_POINTER (quark)); |   g_hash_table_insert (g_quark_ht, string, GUINT_TO_POINTER (quark)); | ||||||
|    |    | ||||||
|   return quark; |   return quark; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user