summary refs log tree commit diff stats
path: root/tests/destructor/tcustomstrings.nim
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2022-08-23 20:44:37 +0300
committerGitHub <noreply@github.com>2022-08-23 19:44:37 +0200
commitf6eb1d4d7d09eee1c366eff44437034e12bbb099 (patch)
tree25ccd3d20b839ee46fd83cd456c75aaddc51434e /tests/destructor/tcustomstrings.nim
parent3dbf2ac9469bdaaf876f902242a883fe1847adf0 (diff)
downloadNim-f6eb1d4d7d09eee1c366eff44437034e12bbb099.tar.gz
remove {.this.} pragma, deprecated since 0.19 (#20201)
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'tests/destructor/tcustomstrings.nim')
-rw-r--r--tests/destructor/tcustomstrings.nim20
1 files changed, 9 insertions, 11 deletions
diff --git a/tests/destructor/tcustomstrings.nim b/tests/destructor/tcustomstrings.nim
index 119bfec2c..31891856b 100644
--- a/tests/destructor/tcustomstrings.nim
+++ b/tests/destructor/tcustomstrings.nim
@@ -8,8 +8,6 @@ after 20 20'''
 joinable: false
 """
 
-{.this: self.}
-
 type
   mystring = object
     len, cap: int
@@ -51,7 +49,7 @@ proc resize(self: var mystring) =
   if self.cap == 0: self.cap = 8
   else: self.cap = (self.cap * 3) shr 1
   if self.data == nil: inc allocCount
-  self.data = cast[type(data)](realloc(self.data, self.cap + 1))
+  self.data = cast[type(self.data)](realloc(self.data, self.cap + 1))
 
 proc add*(self: var mystring; c: char) =
   if self.len >= self.cap: resize(self)
@@ -60,17 +58,17 @@ proc add*(self: var mystring; c: char) =
   inc self.len
 
 proc ensure(self: var mystring; newLen: int) =
-  if newLen >= cap:
-    cap = max((cap * 3) shr 1, newLen)
-    if cap > 0:
-      if data == nil: inc allocCount
-      data = cast[type(data)](realloc(data, cap + 1))
+  if newLen >= self.cap:
+    self.cap = max((self.cap * 3) shr 1, newLen)
+    if self.cap > 0:
+      if self.data == nil: inc allocCount
+      self.data = cast[type(self.data)](realloc(self.data, self.cap + 1))
 
 proc add*(self: var mystring; y: mystring) =
-  let newLen = len + y.len
+  let newLen = self.len + y.len
   ensure(self, newLen)
-  copyMem(addr data[len], y.data, y.data.len + 1)
-  len = newLen
+  copyMem(addr self.data[self.len], y.data, y.data.len + 1)
+  self.len = newLen
 
 proc create*(lit: string): mystring =
   let newLen = lit.len