All it's doing is defining another scope, it's not translated into a method call. Remember that for locals, the CLR/JVM could decide not to use stack space for them at all, it could choose to utilise processor registers. In some cases, if you'll excuse the pun, it could decide to optimise out some of the locals by virtue of them not being needed. It could even decide that it can use one register, or memory location "on the stack" for multiple variables as they're never going to overlap.
Taking the example from the linked question:
switch(condition) {
case CONDITION_ONE: {
int account = 27373;
}
case CONDITION_TWO: {
// account var not needed here
}
case CONDITION_THREE: {
// account var not needed here
}
case CONDITION_FOUR: {
int account = 90384;
}
}
As it stands, that code is functionally identical to:
int account;
switch(condition) {
case CONDITION_ONE: {
account = 27373;
}
case CONDITION_TWO: {
// account var not needed here
}
case CONDITION_THREE: {
// account var not needed here
}
case CONDITION_FOUR: {
account = 90384;
}
}
As the account
variable is never used in multiple cases, which means it's an ideal candidate (in this simplistic example ) for using a register or a single space in memory.