Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show source location in error messages of deferred json #46350

Merged
merged 2 commits into from
Dec 27, 2020

Conversation

Qrox
Copy link
Contributor

@Qrox Qrox commented Dec 27, 2020

Summary

SUMMARY: Infrastructure "Show source location in error messages of deferred json objects"

Purpose of change

Source location did not show correctly for deferred json objects. This PR fixes it.

Describe the solution

  1. Store the data file path and stream offset instead of the JsonObject string, so the deferred json can be loaded using the actual path and display the correct source location.
  2. Use lru_cache to load data files of deferred json so loading performance does not degrade.

Testing

Tested on top of #46337.

Before, without json errors

$ time build/build-tiles/tests/cata_test-tiles.exe --mods="$mods" '~*' >config/test.log 2>&1

real    0m25.374s
user    0m0.000s
sys     0m0.015s

Before, with json errors

$ time build/build-tiles/tests/cata_test-tiles.exe --mods="$mods" '~*' >config/test.log 2>&1

real    0m27.284s
user    0m0.000s
sys     0m0.031s

Error message example

Json error: <unknown source file>:14:10: format: rows: row 11 column 1: 'H' has no terrain, furniture, or other definition

"##=<<            |d d=##",
"##=----------    ----=##",
"H
 ^
  H=b  TTTT          b=##",
"HH= a               nw##",
"##w         ----    nw##",

After, without json errors

$ time build/build-tiles/tests/cata_test-tiles.exe --mods="$mods" '~*' >config/test.log 2>&1

real    0m25.466s
user    0m0.000s
sys     0m0.031s

After, with json errors

$ time build/build-tiles/tests/cata_test-tiles.exe --mods="$mods" '~*' >config/test.log 2>&1

real    0m27.989s
user    0m0.000s
sys     0m0.015s

Error message example

Json error: data/mods//More_Locations/multistory_houses/2story_houses/2storyA_first_03.json:20:10: format: rows: row 11 column 1: 'H' has no terrain, furniture, or other definition

"##=<<            |d d=##",
"##=----------    ----=##",
"H
 ^
  H=b  TTTT          b=##",
"HH= a               nw##",
"##w         ----    nw##",

@Qrox Qrox marked this pull request as draft December 27, 2020 07:15
@Qrox Qrox marked this pull request as ready for review December 27, 2020 07:52
@anothersimulacrum anothersimulacrum added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels Dec 27, 2020
@ZhilkinSerg ZhilkinSerg merged commit b4110fd into CleverRaven:master Dec 27, 2020
@Qrox Qrox deleted the json-check branch December 30, 2020 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants