Forums WoW Modding Support Archives Azerothcore Discord Archives [DiscordArchive] I have some questions that I don't quite understand, so I hope your guys won't laugh at me. just I d

[DiscordArchive] I have some questions that I don't quite understand, so I hope your guys won't laugh at me. just I d

[DiscordArchive] I have some questions that I don't quite understand, so I hope your guys won't laugh at me. just I d

rektbyfaith
Administrator
0
01-23-2025, 05:01 AM
#1
Archived author: leewheel • Posted: 2025-01-23T05:01:39.497000+00:00
Original source

I have some questions that I don't quite understand, so I hope your guys won't laugh at me. just I don't know if anyone can explain my doubts.For example,
``` if (channelName.size() >= 100 || !DisallowHyperlinksAndMaybeKick(channelName))
{
return;
} ```
I think code like this is more standardized and correct, but why do I often see new code being submitted like this?
```
if (channelName.size() >= 100 || !DisallowHyperlinksAndMaybeKick(channelName))
return;
```Does it make the execution more efficient?
rektbyfaith
01-23-2025, 05:01 AM #1

Archived author: leewheel • Posted: 2025-01-23T05:01:39.497000+00:00
Original source

I have some questions that I don't quite understand, so I hope your guys won't laugh at me. just I don't know if anyone can explain my doubts.For example,
``` if (channelName.size() >= 100 || !DisallowHyperlinksAndMaybeKick(channelName))
{
return;
} ```
I think code like this is more standardized and correct, but why do I often see new code being submitted like this?
```
if (channelName.size() >= 100 || !DisallowHyperlinksAndMaybeKick(channelName))
return;
```Does it make the execution more efficient?

rektbyfaith
Administrator
0
01-23-2025, 05:03 AM
#2
Archived author: leewheel • Posted: 2025-01-23T05:03:02.574000+00:00
Original source

Personally, I think the first one is more in line with the regulations, and should not be any different from the second one in terms of execution efficiency.
rektbyfaith
01-23-2025, 05:03 AM #2

Archived author: leewheel • Posted: 2025-01-23T05:03:02.574000+00:00
Original source

Personally, I think the first one is more in line with the regulations, and should not be any different from the second one in terms of execution efficiency.

rektbyfaith
Administrator
0
01-23-2025, 05:06 AM
#3
Archived author: leewheel • Posted: 2025-01-23T05:06:35.751000+00:00
Original source

Possible disadvantages:
Error prone: After removing the curly braces, if you modify the code later and add more statements, you may forget to add the curly braces, resulting in logical errors. For example, the following code may go wrong when modified:
```if (channelName.size() >= 100 || !DisallowHyperlinksAndMaybeKick(channelName))
return;
DoSomethingElse();//This should be executed outside the if statement, but due to the lack of curly braces, it becomes part of the if statement.
```
rektbyfaith
01-23-2025, 05:06 AM #3

Archived author: leewheel • Posted: 2025-01-23T05:06:35.751000+00:00
Original source

Possible disadvantages:
Error prone: After removing the curly braces, if you modify the code later and add more statements, you may forget to add the curly braces, resulting in logical errors. For example, the following code may go wrong when modified:
```if (channelName.size() >= 100 || !DisallowHyperlinksAndMaybeKick(channelName))
return;
DoSomethingElse();//This should be executed outside the if statement, but due to the lack of curly braces, it becomes part of the if statement.
```

rektbyfaith
Administrator
0
01-23-2025, 05:09 AM
#4
Archived author: Honey • Posted: 2025-01-23T05:09:39.058000+00:00
Original source

As far as I remember, parentheses aren't enforced for a single line of code in an if block.
There's no difference in performance.
rektbyfaith
01-23-2025, 05:09 AM #4

Archived author: Honey • Posted: 2025-01-23T05:09:39.058000+00:00
Original source

As far as I remember, parentheses aren't enforced for a single line of code in an if block.
There's no difference in performance.

rektbyfaith
Administrator
0
01-23-2025, 05:31 AM
#5
Archived author: leewheel • Posted: 2025-01-23T05:31:42.452000+00:00
Original source

In the case where there is no difference in performance, I think adding brackets will be more standardized and avoid errors
rektbyfaith
01-23-2025, 05:31 AM #5

Archived author: leewheel • Posted: 2025-01-23T05:31:42.452000+00:00
Original source

In the case where there is no difference in performance, I think adding brackets will be more standardized and avoid errors

rektbyfaith
Administrator
0
01-23-2025, 05:32 AM
#6
Archived author: Kitzunu • Posted: 2025-01-23T05:32:16.496000+00:00
Original source

No, it is just bloating the files. And thus we have decided that oneline if statements do not use curlies
rektbyfaith
01-23-2025, 05:32 AM #6

Archived author: Kitzunu • Posted: 2025-01-23T05:32:16.496000+00:00
Original source

No, it is just bloating the files. And thus we have decided that oneline if statements do not use curlies

rektbyfaith
Administrator
0
01-23-2025, 05:33 AM
#7
Archived author: leewheel • Posted: 2025-01-23T05:33:18.075000+00:00
Original source

then ```if (channelName.size() >= 100 || !DisallowHyperlinksAndMaybeKick(channelName)){return;}```
rektbyfaith
01-23-2025, 05:33 AM #7

Archived author: leewheel • Posted: 2025-01-23T05:33:18.075000+00:00
Original source

then ```if (channelName.size() >= 100 || !DisallowHyperlinksAndMaybeKick(channelName)){return;}```

rektbyfaith
Administrator
0
01-23-2025, 05:34 AM
#8
Archived author: Kitzunu • Posted: 2025-01-23T05:34:19.525000+00:00
Original source

Just follow the guidelines we have
rektbyfaith
01-23-2025, 05:34 AM #8

Archived author: Kitzunu • Posted: 2025-01-23T05:34:19.525000+00:00
Original source

Just follow the guidelines we have

rektbyfaith
Administrator
0
01-23-2025, 05:35 AM
#9
Archived author: leewheel • Posted: 2025-01-23T05:35:06.591000+00:00
Original source

Just my personal opinion, don't make fun of me because I'm a newbie
rektbyfaith
01-23-2025, 05:35 AM #9

Archived author: leewheel • Posted: 2025-01-23T05:35:06.591000+00:00
Original source

Just my personal opinion, don't make fun of me because I'm a newbie

Recently Browsing
 
Recently Browsing