<commit_before># **************************************
#         Nim binding for FUSE
#        (C) 2015 <NAME>
# **************************************

type Buf* = ref object
  p: pointer
  size: int
  pos: int

proc mkBuf*(size: int): Buf =
  var data = newSeq[uint8](size)
  var buf = Buf(
    p: addr(data),
    size: size,
    pos: 0,
  )
  buf

proc mkBuf*(p: pointer, size: int): Buf =
  Buf (
    p: p,
    size: size,
    pos: 0,
  )

proc mkBuf*[T](obj: T): Buf =
  mkBuf(addr(obj), sizeof(T))

proc pos(self: Buf): int =
  self.pos

proc initPos*(self: Buf) =
  self.pos = 0

# Returns current pos as a pointer
proc asPtr*(self: Buf): pointer =
  var n = cast[ByteAddress](self.p)
  cast[pointer](n + self.pos)

proc advance*(self: Buf, n) =
  self.pos += n<commit_msg>update: impl asBuf (read-only view of buffer)<commit_after># **************************************
#         Nim binding for FUSE
#        (C) 2015 <NAME>
# **************************************

type Buf* = ref object
  p: pointer
  size: int
  pos: int

proc mkBuf*(size: int): Buf =
  var data = newSeq[uint8](size)
  var buf = Buf(
    p: addr(data),
    size: size,
    pos: 0,
  )
  buf

proc mkBuf*(p: pointer, size: int): Buf =
  Buf (
    p: p,
    size: size,
    pos: 0,
  )

proc mkBuf*[T](obj: T): Buf =
  mkBuf(addr(obj), sizeof(T))

proc pos(self: Buf): int =
  self.pos

proc initPos*(self: Buf) =
  self.pos = 0

# Returns current pos as a pointer
proc asPtr*(self: Buf): pointer =
  var n = cast[ByteAddress](self.p)
  cast[pointer](n + self.pos)

proc asBuf*(self: Buf): Buf =
  Buf (
    p: self.asPtr,
    size: self.size - self.pos,
    pos: 0,
  )

proc advance*(self: Buf, n) =
  self.pos += n
{'fraction_non_alphanumeric': 0.23176470588235293, 'fraction_numerical': 0.01, 'mean_word_length': 3.021276595744681, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7398460', 'n_tokens_mistral': 671, 'n_tokens_neox': 627, 'n_words': 187}