mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-31 13:05:28 +00:00
Tighter packing of source file contents.
This commit is contained in:
@@ -812,18 +812,17 @@ std::string TracyLlmTools::SourceFile( const std::string& file, uint32_t line, u
|
||||
|
||||
nlohmann::json json = {
|
||||
{ "file", file },
|
||||
{ "contents", nlohmann::json::array() }
|
||||
{ "hint", "Each line starts with a line number, then a <|> symbol, then the actual line content." },
|
||||
};
|
||||
|
||||
std::string contents;
|
||||
for( uint32_t i = minLine; i < maxLine; i++ )
|
||||
{
|
||||
nlohmann::json lineJson = {
|
||||
{ "line", i + 1 },
|
||||
{ "text", lines[i] }
|
||||
};
|
||||
json["contents"].emplace_back( std::move( lineJson ) );
|
||||
contents += std::to_string( i+1 ) + "<|>" + lines[i] + "\n";
|
||||
}
|
||||
|
||||
json.push_back( { "contents", std::move( contents ) } );
|
||||
|
||||
return json.dump( 2, ' ', false, nlohmann::json::error_handler_t::replace );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user