readability

Is “for(;;)” faster than “while (TRUE)”? If not, why do people use it?

左心房为你撑大大i 提交于 2019-11-26 01:35:43
问题 for (;;) { //Something to be done repeatedly } I have seen this sort of thing used a lot, but I think it is rather strange... Wouldn\'t it be much clearer to say while(true) , or something along those lines? I\'m guessing that (as is the reason for many-a-programmer to resort to cryptic code) this is a tiny margin faster? Why, and is it really worth it? If so, why not just define it this way: #define while(true) for(;;) See also: Which is faster: while(1) or while(2)? 回答1: It's not faster. If

Using explicitly numbered repetition instead of question mark, star and plus

≡放荡痞女 提交于 2019-11-25 21:58:44
问题 I\'ve seen regex patterns that use explicitly numbered repetition instead of ? , * and + , i.e.: Explicit Shorthand (something){0,1} (something)? (something){1} (something) (something){0,} (something)* (something){1,} (something)+ The questions are: Are these two forms identical? What if you add possessive/reluctant modifiers? If they are identical, which one is more idiomatic? More readable? Simply \"better\"? 回答1: To my knowledge they are identical. I think there maybe a few engines out