On the efficiency of the writing of logical operators and the problem of the array processing

Source: Internet
Author: User

Recently the company is going to do an information gathering function that requires the employee to fill out the information report but does not want to be open from 0:00 to 6:00 so it's in the process of judging

My idea is to take out the hours of the time and 0-6 to do comparisons if this falls within the range of rejection. The following is an example of what I have written for illustrative

We found that using In_array and range was faster than the logical operator, so I decided to pull the date out of the hour.

The effect is that the discovery does this much faster than the array at the same time and greatly improves efficiency.

But all of this is at the cost of variables: sacrificing space for time

On the efficiency of the writing of logical operators and the problem of the array processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.