From 4046a4c4bd27a800c28431b2e4f52a635f8f9fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20G=2E=20Aragoneses?= Date: Fri, 23 Aug 2013 22:02:16 +0200 Subject: [PATCH 1/2] generator: avoid double lookup in dictionary when DeAlias is called We can avoid a double lookup in the types dictionary here because the method TryGetValue() was just called before. --- generator/SymbolTable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index 7effc54a0..7981a7744 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -213,7 +213,7 @@ namespace GtkSharp.Generation { type = Trim (type); IGeneratable cur_type = null; while (types.TryGetValue (type, out cur_type) && cur_type is AliasGen) { - IGeneratable igen = types [type] as AliasGen; + IGeneratable igen = cur_type as AliasGen; types [type] = types [igen.Name]; type = igen.Name; } From 9327d7d085e1e493f489c028263dc3f9a335828b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20G=2E=20Aragoneses?= Date: Fri, 23 Aug 2013 22:06:29 +0200 Subject: [PATCH 2/2] generator: fix possible unhandled KeyNotFoundException (regression) This regression surfaced after 82a957bc9d3d1fcc44c715a1020fe2afd16c7f4a [1], when many collections were migrated to generic collections. HashTables simply return null when queried for certain key, while Dictionary objects throw KeyNotFoundException. The regression could be noticed, more particularly, when trying to compile the gtk3 branch of the gudevsharp project [2]. [1] https://github.com/mono/gtk-sharp/commit/82a957bc9d3d1fcc44c715a1020fe2afd16c7f4a [2] https://github.com/mono/gudev-sharp/commits/gtk3 --- generator/SymbolTable.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index 7981a7744..4ace94446 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -214,7 +214,12 @@ namespace GtkSharp.Generation { IGeneratable cur_type = null; while (types.TryGetValue (type, out cur_type) && cur_type is AliasGen) { IGeneratable igen = cur_type as AliasGen; - types [type] = types [igen.Name]; + + IGeneratable new_type; + if (!types.TryGetValue (igen.Name, out new_type)) + new_type = null; + + types [type] = new_type; type = igen.Name; }