Skip to content

Commit

Permalink
Remove old cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
devinus committed Jul 22, 2021
1 parent a68a90b commit e074e17
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
executors:
elixir:
docker:
- image: cimg/elixir:1.12.1
- image: cimg/elixir:1.12.2
environment:
MIX_ENV: test

Expand Down
3 changes: 2 additions & 1 deletion .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
# You can customize the priority of any check
# Priority values are: `low, normal, high, higher`
#
{Credo.Check.Design.AliasUsage, [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
{Credo.Check.Design.AliasUsage,
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
Expand Down
3 changes: 1 addition & 2 deletions .formatter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
inputs: [
"{mix,.credo,.formatter}.exs",
"{config,lib,test,bench,profile}/**/*.{ex,exs}"
],
line_length: 120
]
]
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 24.0.2
elixir 1.12.1-otp-24
erlang 24.0.3
elixir 1.12.2-otp-24
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dist: focal
sudo: false
language: elixir
elixir:
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.4
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.watcherExclude": {
"**/target": true
}
},
"elixirLS.enableTestLenses": true,
"elixirLS.dialyzerWarnOpts": ["no_improper_lists"]
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM elixir:1.12.1-alpine as base
FROM elixir:1.12.2-alpine as base
ARG MIX_ENV
ENV MIX_ENV ${MIX_ENV:-test}
RUN apk --no-cache add git build-base
Expand Down
38 changes: 0 additions & 38 deletions config/config.exs

This file was deleted.

3 changes: 0 additions & 3 deletions config/profile.exs

This file was deleted.

16 changes: 0 additions & 16 deletions dialyzer.ignore-warnings

This file was deleted.

82 changes: 41 additions & 41 deletions lib/poison/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ defmodule Poison.Parser do
@compile {:inline_size, 150}
@compile {:inline_unroll, 3}

if Application.get_env(:poison, :native) do
@compile [:native, {:hipe, [:o3]}]
end

use Bitwise

alias Poison.{Decoder, ParseError}
Expand All @@ -81,14 +77,6 @@ defmodule Poison.Parser do
whitespace = '\s\t\n\r'
digits = ?0..?9

defmacrop stacktrace do
if Version.compare(System.version(), "1.7.0") != :lt do
quote do: __STACKTRACE__
else
quote do: System.stacktrace()
end
end

defmacrop syntax_error(skip) do
quote do
raise ParseError, skip: unquote(skip)
Expand All @@ -99,12 +87,16 @@ defmodule Poison.Parser do
def parse!(value, options \\ %{})

def parse!(data, options) when is_bitstring(data) do
[value | skip] = value(data, data, :maps.get(:keys, options, nil), :maps.get(:decimal, options, nil), 0)
[value | skip] =
value(data, data, :maps.get(:keys, options, nil), :maps.get(:decimal, options, nil), 0)

<<_::binary-size(skip), rest::bits>> = data
skip_whitespace(rest, skip, value)
rescue
exception in ParseError ->
reraise ParseError, [data: data, skip: exception.skip, value: exception.value], stacktrace()
reraise ParseError,
[data: data, skip: exception.skip, value: exception.value],
__STACKTRACE__
end

def parse!(iodata, options) do
Expand Down Expand Up @@ -175,22 +167,22 @@ defmodule Poison.Parser do
## Objects

defmacrop object_name(keys, skip, name) do
quote do
case unquote(keys) do
quote bind_quoted: [keys: keys, skip: skip, name: name] do
case keys do
:atoms! ->
try do
String.to_existing_atom(unquote(name))
String.to_existing_atom(name)
rescue
ArgumentError ->
reraise ParseError, [skip: unquote(skip), value: unquote(name)], stacktrace()
reraise ParseError, [skip: skip, value: name], __STACKTRACE__
end

:atoms ->
# credo:disable-for-next-line Credo.Check.Warning.UnsafeToAtom
String.to_atom(unquote(name))
String.to_atom(name)

_keys ->
unquote(name)
name
end
end
end
Expand All @@ -200,12 +192,14 @@ defmodule Poison.Parser do
defp object_pairs(<<?", rest::bits>>, data, keys, decimal, skip, acc) do
start = skip + 1
[name | skip] = string_continue(rest, data, start)

<<_::binary-size(skip), rest::bits>> = data
[value | skip] = object_value(rest, data, keys, decimal, skip)

[value | skip] = object_value(rest, data, keys, decimal, skip)
<<_::binary-size(skip), rest::bits>> = data
object_pairs_continue(rest, data, keys, decimal, skip, [{object_name(keys, start, name), value} | acc])

object_pairs_continue(rest, data, keys, decimal, skip, [
{object_name(keys, start, name), value} | acc
])
end

defp object_pairs(<<?}, _rest::bits>>, _data, _keys, _decimal, skip, []) do
Expand Down Expand Up @@ -274,19 +268,15 @@ defmodule Poison.Parser do

defp array_values(rest, data, keys, decimal, skip, acc) do
[value | skip] = value(rest, data, keys, decimal, skip)

<<_::binary-size(skip), rest::bits>> = data

array_values_continue(rest, data, keys, decimal, skip, [value | acc])
end

@compile {:inline, array_values_continue: 6}

defp array_values_continue(<<?,, rest::bits>>, data, keys, decimal, skip, acc) do
[value | skip] = value(rest, data, keys, decimal, skip + 1)

<<_::binary-size(skip), rest::bits>> = data

array_values_continue(rest, data, keys, decimal, skip, [value | acc])
end

Expand Down Expand Up @@ -427,25 +417,31 @@ defmodule Poison.Parser do
end

defp number_complete(_decimal, skip, sign, coef, 0) do
[sign * coef | skip]
[coef * sign | skip]
end

max_sig = 1 <<< 53

# See: https://arxiv.org/pdf/2101.11408.pdf
defp number_complete(_decimal, skip, sign, coef, exp) when exp in -10..10 and coef <= unquote(max_sig) do
defp number_complete(_decimal, skip, sign, coef, exp)
when exp in -10..10 and coef <= unquote(max_sig) do
if exp < 0 do
[sign * coef / pow10(-exp) | skip]
[coef / pow10(-exp) * sign | skip]
else
[sign * coef * pow10(exp) | skip]
[coef * pow10(exp) * sign | skip]
end
end

defp number_complete(_decimal, skip, sign, coef, exp) do
[String.to_float(<<Integer.to_string(sign * coef)::bits, ".0e"::bits, Integer.to_string(exp)::bits>>) | skip]
[
String.to_float(
<<Integer.to_string(coef * sign)::bits, ".0e"::bits, Integer.to_string(exp)::bits>>
)
| skip
]
rescue
ArithmeticError ->
reraise ParseError, [skip: skip, value: "#{sign * coef}e#{exp}"], stacktrace()
reraise ParseError, [skip: skip, value: "#{coef * sign}e#{exp}"], __STACKTRACE__
end

@compile {:inline, pow10: 1}
Expand All @@ -459,10 +455,10 @@ defmodule Poison.Parser do
## Strings

defmacrop string_codepoint_size(codepoint) do
quote do
quote bind_quoted: [codepoint: codepoint] do
cond do
unquote(codepoint) <= 0x7FF -> 2
unquote(codepoint) <= 0xFFFF -> 3
codepoint <= 0x7FF -> 2
codepoint <= 0xFFFF -> 3
true -> 4
end
end
Expand Down Expand Up @@ -490,7 +486,10 @@ defmodule Poison.Parser do
end

unicode ->
[:unicode.characters_to_binary([acc | binary_part(data, skip, len)], :utf8) | skip + len + 1]
[
:unicode.characters_to_binary([acc | binary_part(data, skip, len)], :utf8)
| skip + len + 1
]

true ->
[IO.iodata_to_binary([acc | binary_part(data, skip, len)]) | skip + len + 1]
Expand All @@ -505,7 +504,8 @@ defmodule Poison.Parser do
string_continue(rest, data, skip, unicode, len + 1, acc)
end

defp string_continue(<<codepoint::utf8, rest::bits>>, data, skip, _unicode, len, acc) when codepoint > 0x80 do
defp string_continue(<<codepoint::utf8, rest::bits>>, data, skip, _unicode, len, acc)
when codepoint > 0x80 do
string_continue(rest, data, skip, true, len + string_codepoint_size(codepoint), acc)
end

Expand Down Expand Up @@ -540,12 +540,12 @@ defmodule Poison.Parser do
defguardp is_surrogate_pair(hi, lo) when hi in 0xD800..0xDBFF and lo in 0xDC00..0xDFFF

defmacrop get_codepoint(seq, skip) do
quote do
quote bind_quoted: [seq: seq, skip: skip] do
try do
String.to_integer(unquote(seq), 16)
String.to_integer(seq, 16)
rescue
ArgumentError ->
reraise ParseError, [skip: unquote(skip), value: "\\u#{unquote(seq)}"], stacktrace()
reraise ParseError, [skip: skip, value: "\\u#{seq}"], __STACKTRACE__
end
end
end
Expand Down
14 changes: 13 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ defmodule Poison.Mixfile do
deps: deps(),
docs: docs(),
package: package(),
aliases: aliases(),
xref: [exclude: [Decimal]],
dialyzer: [
ignore_warnings: ".dialyzer_ignore.exs",
Expand Down Expand Up @@ -70,7 +71,7 @@ defmodule Poison.Mixfile do
{:credo, "~> 1.5", only: [:dev, :test], runtime: false},
{:decimal, "~> 2.0", optional: true},
{:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.24", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.25", only: [:dev, :test], runtime: false},
{:excoveralls, "~> 0.14", only: :test, runtime: false},
{:exjsx, "~> 4.0", only: [:bench, :profile], runtime: false},
{:jason, "~> 1.2", only: [:dev, :test, :bench, :profile], runtime: false},
Expand Down Expand Up @@ -99,4 +100,15 @@ defmodule Poison.Mixfile do
links: %{"GitHub" => "https://github.com/devinus/poison"}
]
end

defp aliases do
[
"deps.get": [
fn _ ->
System.cmd("git", ["submodule", "update", "--init"], cd: __DIR__, parallelism: true)
end,
"deps.get"
]
]
end
end
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"},
"ex_doc": {:hex, :ex_doc, "0.25.0", "4070a254664ee5495c2f7cce87c2f43064a8752f7976f2de4937b65871b05223", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2d90883bd4f3d826af0bde7fea733a4c20adba1c79158e2330f7465821c8949b"},
"excoveralls": {:hex, :excoveralls, "0.14.1", "14140e4ef343f2af2de33d35268c77bc7983d7824cb945e6c2af54235bc2e61f", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "4a588f9f8cf9dc140cc1f3d0ea4d849b2f76d5d8bee66b73c304bb3d3689c8b0"},
"exjsx": {:hex, :exjsx, "4.0.0", "60548841e0212df401e38e63c0078ec57b33e7ea49b032c796ccad8cde794b5c", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm", "32e95820a97cffea67830e91514a2ad53b888850442d6d395f53a1ac60c82e07"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
Expand All @@ -19,7 +19,7 @@
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
"jiffy": {:hex, :jiffy, "1.0.8", "60e36f00be35e5ac6e6cf2d4caf3bdf3103d4460aff385f543a8d7df2d6d9613", [:rebar3], [], "hexpm", "f9ae986ba5a0854eb48cf6a76192d9367086da86c20197da430630be7c087a4e"},
"json": {:hex, :json, "1.4.1", "8648f04a9439765ad449bc56a3ff7d8b11dd44ff08ffcdefc4329f7c93843dfa", [:mix], [], "hexpm", "9abf218dbe4ea4fcb875e087d5f904ef263d012ee5ed21d46e9dbca63f053d16"},
"jsone": {:hex, :jsone, "1.6.0", "4ed7e456cff24ff153c2eac7e1855797ea1b1416ef0bbc368525ed8cbeb57518", [:rebar3], [], "hexpm", "9e5623ac927a278086a3e758537c68f312f6b16a2d0582a0d1c8a58bd4a939db"},
"jsone": {:hex, :jsone, "1.6.1", "7ea1098fe004c4127320fe0e3cf6a951b01f82039feaa56c322dc7e34dd59762", [:rebar3], [], "hexpm", "a6c1df6081df742068d2ed747a4fe8a7740c56421b53e02bc9d4907dd3502922"},
"jsx": {:hex, :jsx, "2.8.3", "a05252d381885240744d955fbe3cf810504eb2567164824e19303ea59eef62cf", [:mix, :rebar3], [], "hexpm", "fc3499fed7a726995aa659143a248534adc754ebd16ccd437cd93b649a95091f"},
"junit_formatter": {:hex, :junit_formatter, "3.3.0", "bd7914d92885f7cf949dbe1dc6bacf76badfb2c1f5f7b3f9433c20e5b6ec42c8", [:mix], [], "hexpm", "4d040410925324b155ae4c7d41e884a0cdebe53b917bee4f22adf152e987a666"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
Expand Down
Loading

0 comments on commit e074e17

Please sign in to comment.