のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

pango_find_map

152 PangoMap *
153 pango_find_map (PangoLanguage *language,
154		guint          engine_type_id,
155		guint          render_type_id)
156 {
157     GList *tmp_list;
158     PangoMapInfo *map_info = NULL;
159     gboolean found_earlier = FALSE;
160
161     G_LOCK (maps);
162
163     tmp_list = maps;
164     while (tmp_list)
165     {
166         map_info = tmp_list->data;
167         if (map_info->engine_type_id == engine_type_id &&
168             map_info->render_type_id == render_type_id)
169         {
170             if (map_info->language == language)
171                  break;
172             else
173                  found_earlier = TRUE;
174          }
175   
176          tmp_list = tmp_list->next;
177     }
178
179     if (!tmp_list)
180     {
181          map_info = g_slice_new (PangoMapInfo);
182         map_info->language = language;
183         map_info->engine_type_id = engine_type_id;
184         map_info->render_type_id = render_type_id;
185
186         build_map (map_info);
187
188         maps = g_list_prepend (maps, map_info);
189     }
190     else if (found_earlier)
191      {
192         /* Move the found map to the beginning of the list
193          * for speed next time around if we had to do
194          * any failing comparison. (No longer so important,
195          * since we don't strcmp.)
196          */
197         maps = g_list_remove_link(maps, tmp_list);
198         maps = g_list_prepend(maps, tmp_list->data);
199         g_list_free_1(tmp_list);
200     }
201
202     G_UNLOCK (maps);
203
204     return map_info->map;
205 }