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 6153355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:04:51+00:00 2026-05-23T20:04:51+00:00

In one of my C application I am using, below functions from ctype.h :

  • 0

In one of my C application I am using, below functions from ctype.h :

isalpha(), isspace(), ispunct(), tolower().

After profiling I see there are some bottlenecks in the calls of these functions(Basically my app is a character/string processing from a input text file and hence these functions are called exhaustively inside critical loops)I want to optimize them for speed and have my own implementation if it helps.

Where can I find such or logic to implement them?

  • 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-23T20:04:51+00:00Added an answer on May 23, 2026 at 8:04 pm

    It sounds to me odd that such functions can be your bottleneck; likely they can take into account the locale, and this makes them “slower”. If you can disregard it, then you can implement them as easily as (e.g.: this is just an idea wrote on the fly)

    bool isalpha(int c)
    {
       return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
    }
    
    bool isspace(int c)
    {
       return c == ' ' || c == '\t'; // || whatever other char you consider space
    }
    
    bool ispunct(int c)
    {
       static const char *punct = ".;!?...";
       return strchr(punct, c) == NULL ? false : true; // you can make this shorter
    }
    
    int tolower(int c)
    {
       if ( !isalpha(c) ) return c;
       return (c >= 'A' && c <= 'Z') ? c - 'A' : c;
    }
    

    Then make them inline functions.

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

Sidebar

Related Questions

I did one sample application using WebView, in that web view the URL comes
I'm developing one application for iphone using phone gap.I that I need to display
I have a funny event with one application in development using OpenGL ES on
I am creating one application in which i am using jsp/servlet.. I want to
i have one application which is build using VB.NET now i required to add
I have created one application in flex that is accessing the Java webservice using
I am using CI + smarty + dojo framework in my one application. I
I am developing an web application using php. One of the requirement is the
I have built a web application using Java EE platform that sells one of
I`m developing an application using Spring WebFlow 2, Facelets and JSF. One of my

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.