summary refs log tree commit diff stats
path: root/lib/core
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2021-04-17 17:48:22 +0800
committerGitHub <noreply@github.com>2021-04-17 11:48:22 +0200
commit5c5f356347b15a82491c7f23e9bf2dd30a0c80f2 (patch)
tree5900b4a5a8d50c32be258a0abe02cf1529b59c83 /lib/core
parent7e94420847d2d18347410099e97195ddebe8b85f (diff)
downloadNim-5c5f356347b15a82491c7f23e9bf2dd30a0c80f2.tar.gz
replace defer with try ... finally (#17753)
Diffstat (limited to 'lib/core')
-rw-r--r--lib/core/rlocks.nim10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/core/rlocks.nim b/lib/core/rlocks.nim
index 27a9c5e60..f9224adb8 100644
--- a/lib/core/rlocks.nim
+++ b/lib/core/rlocks.nim
@@ -47,9 +47,9 @@ proc release*(lock: var RLock) =
 
 template withRLock*(lock: var RLock, code: untyped): untyped =
   ## Acquires the given lock and then executes the code.
-  block:
-    acquire(lock)
-    defer:
-      release(lock)
-    {.locks: [lock].}:
+  acquire(lock)
+  {.locks: [lock].}:
+    try:
       code
+    finally:
+      release(lock)