From f2c81f1fc53e2124132dda99bccabc1873cf7759 Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Sun, 24 Jan 2016 21:21:37 +0100 Subject: [PATCH] Small improvements --- private/presenter.nim | 8 ++++---- yaml/serialization.nim | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/private/presenter.nim b/private/presenter.nim index 6f58f5e..e806e5d 100644 --- a/private/presenter.nim +++ b/private/presenter.nim @@ -164,7 +164,7 @@ proc present*(s: YamlStream, target: Stream, tagLib: TagLibrary, if finished(s): break cached.enqueue(item) - except: + except Exception: var e = newException(YamlPresenterStreamError, "") e.parent = getCurrentException() raise e @@ -257,7 +257,7 @@ proc present*(s: YamlStream, target: Stream, tagLib: TagLibrary, else: length = high(int) break - except: + except Exception: var e = newException(YamlPresenterStreamError, "") e.parent = getCurrentException() raise e @@ -322,7 +322,7 @@ proc present*(s: YamlStream, target: Stream, tagLib: TagLibrary, break else: mps = mpNeedBlock - except: + except Exception: var e = newException(YamlPresenterStreamError, "") e.parent = getCurrentException() raise e @@ -448,7 +448,7 @@ proc present*(s: YamlStream, target: Stream, tagLib: TagLibrary, if finished(s): break cached.enqueue(next) - except: + except Exception: var e = newException(YamlPresenterStreamError, "") e.parent = getCurrentException() raise e diff --git a/yaml/serialization.nim b/yaml/serialization.nim index 23591a2..cc5dc6e 100644 --- a/yaml/serialization.nim +++ b/yaml/serialization.nim @@ -144,7 +144,7 @@ macro serializable*(types: stmt): stmt = while event.kind != yamlEndMap: assert event.kind == yamlScalar assert event.scalarTag in [yTagQuestionMark, yTagString] - case hash(event.scalarContent) + case event.scalarContent else: raise newException(YamlConstructionError, "Unknown key for " & `tName` & ": " & @@ -154,9 +154,8 @@ macro serializable*(types: stmt): stmt = var keyCase = impl[5][1][2] assert keyCase.kind == nnkCaseStmt for field in objectFields(recList): - let nameHash = hash($field.name.ident) keyCase.insert(1, newNimNode(nnkOfBranch).add( - newIntLitNode(nameHash)).add(newStmtList( + newStrLitNode($field.name.ident)).add(newStmtList( newCall("construct", [newIdentNode("s"), newDotExpr( newIdentNode("result"), field.name)]) ))