diff options
author | Eric Avdey <eiri@eiri.ca> | 2018-01-12 10:56:18 -0400 |
---|---|---|
committer | Eric Avdey <eiri@eiri.ca> | 2018-01-12 13:05:15 -0400 |
commit | 1768aeab8b9100034e374a45f1bc9b7bd72dad2e (patch) | |
tree | 7792bcf735b6ba9c7b1aecb3b6cfdbfefe56b4ec | |
parent | 730dcf795117c51939e491b04400757f8d61a9f6 (diff) | |
download | couchdb-1768aeab8b9100034e374a45f1bc9b7bd72dad2e.tar.gz |
Remove warning on `couch_epi_codegen` compile
Change runtime choice between `erl_scan:token_info`
and `erl_scan:line` to compilation conditional one.
This is getting rid of compilation deprecation warning
and also should speed up things a bit.
-rw-r--r-- | src/couch_epi/rebar.config | 4 | ||||
-rw-r--r-- | src/couch_epi/src/couch_epi_codegen.erl | 19 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/couch_epi/rebar.config b/src/couch_epi/rebar.config index 82db830a2..3c7f8af73 100644 --- a/src/couch_epi/rebar.config +++ b/src/couch_epi/rebar.config @@ -1,3 +1,7 @@ {cover_enabled, true}. {cover_print_enabled, true}. + +{erl_opts, [ + {platform_define, "^R16", 'pre18'}, + {platform_define, "^17", 'pre18'}]}. diff --git a/src/couch_epi/src/couch_epi_codegen.erl b/src/couch_epi/src/couch_epi_codegen.erl index 978f0bb58..89b82a1f9 100644 --- a/src/couch_epi/src/couch_epi_codegen.erl +++ b/src/couch_epi/src/couch_epi_codegen.erl @@ -70,11 +70,16 @@ fixup_terminator(Tokens) -> Tokens ++ [{dot, Line}] end. + +-ifdef(pre18). + line(Token) -> - case erlang:function_exported(erl_scan, line, 1) of - true -> - erl_scan:line(Token); - false -> - {line, Line} = erl_scan:token_info(Token, line), - Line - end. + {line, Line} = erl_scan:token_info(Token, line), + Line. + +-else. + +line(Token) -> + erl_scan:line(Token). + +-endif. |