Created
February 14, 2017 21:33
-
-
Save psiphi75/41417135e9ee82192a8d5a65993e4d19 to your computer and use it in GitHub Desktop.
Example of polymorphic and monomorphic code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(a, b) { | |
return a + b; | |
} | |
add(1, 2); // Starts as monomorphic | |
add(2, 3); // Still monomorphic | |
add('x', 'y'); // Now becomes polymorphic - bad for optimisation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment