Skip to content

Commit 31c91e5

Browse files
committed
refactor: simplify branching to optimize most common path
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent dda0844 commit 31c91e5

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

  • lib/node_modules/@stdlib/ndarray/base/consensus-order

lib/node_modules/@stdlib/ndarray/base/consensus-order/lib/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ var DEFAULT_ORDER = defaults.get( 'order' );
5656
* // returns <string>
5757
*/
5858
function resolveString( layout ) {
59-
if ( layout === 0 || layout === 3 ) {
60-
return DEFAULT_ORDER;
61-
}
6259
if ( layout === 1 ) {
6360
return 'row-major';
6461
}
65-
// layout === 2
66-
return 'column-major';
62+
if ( layout === 2 ) {
63+
return 'column-major';
64+
}
65+
// layout === 0 || layout === 3
66+
return DEFAULT_ORDER;
6767
}
6868

6969

lib/node_modules/@stdlib/ndarray/base/consensus-order/test/test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ tape( 'the function returns a storage layout (mixed order)', function test( t )
8686
t.end();
8787
});
8888

89+
tape( 'the function returns a storage layout (mixed order, tie)', function test( t ) {
90+
var sx;
91+
var sy;
92+
var o;
93+
94+
sx = [ 4, -2, 1 ]; // row-major
95+
sy = [ 1, -4, -8 ]; // column-major
96+
97+
o = consensusOrder( [ sx, sy, sx, sy ] );
98+
t.strictEqual( o, DEFAULT_ORDER, 'returns expected value' );
99+
100+
t.end();
101+
});
102+
89103
tape( 'the function returns a storage layout (both orders)', function test( t ) {
90104
var sx;
91105
var sy;

0 commit comments

Comments
 (0)