0

説明のために 2 つの関数を作成しました。どちらがより良い練習になるか教えていただけますか?

Test2 は、より少ない変数を宣言する必要があるため、システムで使用するメモリが少ないため、パフォーマンスが優れていますか?

Function Test1()

    Dim PerformMethod_A As Boolean = True
    Dim a = 1
    Dim b = 2
    Dim c = 3
    Dim d = 4
    Dim e = 5
    Dim result

    If PerformMethod_A Then
        result = a + b
    Else
        result = c + d + e
    End If

    Return result

End Function

Function Test2()

    Dim PerformMethod_A As Boolean = True
    Dim result

    If PerformMethod_A Then
        Dim a = 1
        Dim b = 2
        result = a + b
    Else
        Dim c = 3
        Dim d = 4
        Dim e = 5
        result = c + d + e
    End If

    Return result

End Function
4

2 に答える 2