<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Capacity on Nalar</title>
    <link>https://nalar.dev/tags/capacity/</link>
    <description>Recent content in Capacity on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 12 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/capacity/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Limit Go Slice Capacity with slices.Clip</title>
      <link>https://nalar.dev/limit-go-slice-capacity-with-slices-clip/</link>
      <pubDate>Sat, 12 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/limit-go-slice-capacity-with-slices-clip/</guid>
      <description>&lt;p&gt;A Go slice can be short while still carrying much more capacity than its current length. That extra capacity is useful when more elements are expected, but sometimes code should hand off a slice without leaving room for an &lt;code&gt;append&lt;/code&gt; to reuse the same tail. &lt;code&gt;slices.Clip&lt;/code&gt; gives that intent a direct operation.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Clip&lt;/code&gt; returns a slice with the same elements and length, but its capacity is reduced to its length.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Reserve Go Slice Capacity with slices.Grow</title>
      <link>https://nalar.dev/reserve-go-slice-capacity-with-slices-grow/</link>
      <pubDate>Fri, 11 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/reserve-go-slice-capacity-with-slices-grow/</guid>
      <description>&lt;p&gt;Repeated &lt;code&gt;append&lt;/code&gt; calls can force a Go slice to move to a larger backing array when its capacity runs out. If code already knows that several more elements are about to arrive, &lt;code&gt;slices.Grow&lt;/code&gt; can reserve enough room before those appends happen.&lt;/p&gt;&#xA;&lt;p&gt;The key detail is that &lt;code&gt;slices.Grow&lt;/code&gt; changes capacity when needed, not length. Existing elements stay in place logically, and the returned slice still contains the same number of elements.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
