<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/43-less-code-with-a-better-data-structure-ifhfuq8ck" -->

---
title: 43% Less Code With A Better Data Structure | daily.dev
description: The most impactful step is to use a Set instead of the array as the. The Set is a slightly better fit here as we only need to know the ids of all selected...
canonical: https://daily.dev/posts/43-less-code-with-a-better-data-structure-ifhfuq8ck
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: 43% Less Code With A Better Data Structure | daily.dev
og:description: The most impactful step is to use a Set instead of the array as the. The Set is a slightly better fit here as we only need to know the ids of all selected...
og:url: https://daily.dev/posts/43-less-code-with-a-better-data-structure-ifhfuq8ck
og:image: https://api.daily.dev/og/posts/iFhFUq8CK.png
og:image:alt: 43% Less Code With A Better Data Structure
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 43% Less Code With A Better Data Structure

**[Community Picks](https://daily.dev/sources/community)** · 14 min read · 32 upvotes · 0 comments

## Summary

The most impactful step is to use a Set instead of the array as the. The Set is a slightly better fit here as we only need to know the ids of all selected items instead of a key-value pair. As we’ve analyzed some of the problems with the original code let’s start to refactor it step by step. The change isn’t trivial.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://profy.dev/article/react-junior-code-review-and-refactoring-1>

---

Tags: [#react](https://daily.dev/tags/react)

[View this post on daily.dev](https://daily.dev/posts/43-less-code-with-a-better-data-structure-ifhfuq8ck)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"43% Less Code With A Better Data Structure","url":"https://daily.dev/posts/43-less-code-with-a-better-data-structure-ifhfuq8ck","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/43-less-code-with-a-better-data-structure-ifhfuq8ck"},"datePublished":"2022-11-12T07:14:47.690Z","dateModified":"2023-12-07T12:02:45.284Z","description":"The most impactful step is to use a Set instead of the array as the. The Set is a slightly better fit here as we only need to know the ids of all selected...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d8b211a8da4f27f47fe2ede1fa7f26bd","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d8b211a8da4f27f47fe2ede1fa7f26bd","isAccessibleForFree":true,"articleSection":"Community Picks","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Community Picks","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1655817725/logos/community","url":"https://daily.dev/sources/community"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/43-less-code-with-a-better-data-structure-ifhfuq8ck","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":32},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"react","timeRequired":"PT14M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Community Picks","item":"https://daily.dev/sources/community"},{"@type":"ListItem","position":3,"name":"43% Less Code With A Better Data Structure"}]}
```

