Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 497661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:48:10+00:00 2026-05-13T05:48:10+00:00

I’m working on a mobile phone application and I see a potential opportunity for

  • 0

I’m working on a mobile phone application and I see a potential opportunity for performance improvement. Throughout the code I use bool arrays to keep track of which objects are active. For example I’d check to see if the ith MyObject is active by doing the following:

if(activeMyObjects[i]){ // it's active so do something... }

Since the max number of my objects is in the range [5,20] I think I can replace the activeMyObjects bool array with a bitset in the form of a single integer “activeMyObjects”. Then I can do the following:

// check if ith object is active
if(activeMyObjects & (1 << i)){ // it's active... }

// activate the ith object
activeMyObjects |= (1 << i);

// reset all myObjects to inactive
activeMyObjects = 0;

// and so on...

Is there anytime when switching to the bitset could actually degrade performance? The language I’m using is c. Also note this code is called very often (frequency in the range 30 – 60 Hz).

Edit:
Another piece of information: the bitsets have another advantage in that I can easily tell if any of the objects are active at all. so I can skip a loop where I check each item to see if it’s active by first checking if(activeMyObjects). when I use the array this is trickier… my approach was to have an additional counter int which is incremented whenever a MyObject is actived and decremented whenever a MyObject is deactivated… this way I would just check if(activeMyObjectsCount > 0) before the loop where I check each one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:48:11+00:00Added an answer on May 13, 2026 at 5:48 am

    Depending on how often the bitset is allocated, you can easily end up occupying more memory with the bitset version.

    The code to access a particular bit is much larger than the code to access a full byte of memory – if there’s only going to be a handful of these arrays, but it’s accessed often, you’ll get a smaller footprint leaving it like it is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.