mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	code: Use std::span where appropriate (#6658)
* code: Use std::span when possible * code: Prefix memcpy and memcmp with std::
This commit is contained in:
		
							parent
							
								
									4ccd9f24fb
								
							
						
					
					
						commit
						cf9bb90ae3
					
				
					 106 changed files with 362 additions and 329 deletions
				
			
		|  | @ -129,7 +129,7 @@ void ConfigurePerGame::HandleApplyButtonClicked() { | |||
| 
 | ||||
| static QPixmap GetQPixmapFromSMDH(std::vector<u8>& smdh_data) { | ||||
|     Loader::SMDH smdh; | ||||
|     memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); | ||||
|     std::memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); | ||||
| 
 | ||||
|     bool large = true; | ||||
|     std::vector<u16> icon_data = smdh.GetIcon(large); | ||||
|  |  | |||
|  | @ -487,7 +487,7 @@ void GraphicsVertexShaderWidget::Reload(bool replace_vertex_data, void* vertex_d | |||
| 
 | ||||
|     if (replace_vertex_data) { | ||||
|         if (vertex_data) { | ||||
|             memcpy(&input_vertex, vertex_data, sizeof(input_vertex)); | ||||
|             std::memcpy(&input_vertex, vertex_data, sizeof(input_vertex)); | ||||
|             for (unsigned attr = 0; attr < 16; ++attr) { | ||||
|                 for (unsigned comp = 0; comp < 4; ++comp) { | ||||
|                     input_data[4 * attr + comp]->setText( | ||||
|  |  | |||
|  | @ -18,7 +18,7 @@ QString RecordDialog::FormatObject(const IPCDebugger::ObjectInfo& object) const | |||
|         .arg(object.id, 8, 16, QLatin1Char('0')); | ||||
| } | ||||
| 
 | ||||
| QString RecordDialog::FormatCmdbuf(const std::vector<u32>& cmdbuf) const { | ||||
| QString RecordDialog::FormatCmdbuf(std::span<const u32> cmdbuf) const { | ||||
|     QString result; | ||||
|     for (std::size_t i = 0; i < cmdbuf.size(); ++i) { | ||||
|         result.append( | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ | |||
| 
 | ||||
| #include <array> | ||||
| #include <memory> | ||||
| #include <span> | ||||
| #include <string> | ||||
| #include <vector> | ||||
| #include <QDialog> | ||||
|  | @ -28,7 +29,7 @@ public: | |||
| 
 | ||||
| private: | ||||
|     QString FormatObject(const IPCDebugger::ObjectInfo& object) const; | ||||
|     QString FormatCmdbuf(const std::vector<u32>& cmdbuf) const; | ||||
|     QString FormatCmdbuf(std::span<const u32> cmdbuf) const; | ||||
|     void UpdateCmdbufDisplay(); | ||||
| 
 | ||||
|     std::unique_ptr<Ui::RecordDialog> ui; | ||||
|  |  | |||
|  | @ -64,7 +64,7 @@ WaitTreeItem* WaitTreeItem::Parent() const { | |||
|     return parent; | ||||
| } | ||||
| 
 | ||||
| const std::vector<std::unique_ptr<WaitTreeItem>>& WaitTreeItem::Children() const { | ||||
| std::span<const std::unique_ptr<WaitTreeItem>> WaitTreeItem::Children() const { | ||||
|     return children; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ | |||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <span> | ||||
| #include <QAbstractItemModel> | ||||
| #include <QDockWidget> | ||||
| #include <QTreeView> | ||||
|  | @ -36,7 +37,7 @@ public: | |||
| 
 | ||||
|     void Expand(); | ||||
|     WaitTreeItem* Parent() const; | ||||
|     const std::vector<std::unique_ptr<WaitTreeItem>>& Children() const; | ||||
|     std::span<const std::unique_ptr<WaitTreeItem>> Children() const; | ||||
|     std::size_t Row() const; | ||||
|     static std::vector<std::unique_ptr<WaitTreeThread>> MakeThreadItemList(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <memory> | ||||
| #include <vector> | ||||
| #include <QDialog> | ||||
| #include "core/dumping/ffmpeg_backend.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -6,8 +6,10 @@ | |||
| 
 | ||||
| #include <algorithm> | ||||
| #include <map> | ||||
| #include <span> | ||||
| #include <unordered_map> | ||||
| #include <utility> | ||||
| #include <vector> | ||||
| #include <QCoreApplication> | ||||
| #include <QFileInfo> | ||||
| #include <QImage> | ||||
|  | @ -153,7 +155,7 @@ public: | |||
|     static constexpr int LongTitleRole = SortRole + 5; | ||||
| 
 | ||||
|     GameListItemPath() = default; | ||||
|     GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id, | ||||
|     GameListItemPath(const QString& game_path, std::span<const u8> smdh_data, u64 program_id, | ||||
|                      u64 extdata_id) { | ||||
|         setData(type(), TypeRole); | ||||
|         setData(game_path, FullPathRole); | ||||
|  | @ -178,7 +180,7 @@ public: | |||
|         } | ||||
| 
 | ||||
|         Loader::SMDH smdh; | ||||
|         memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); | ||||
|         std::memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); | ||||
| 
 | ||||
|         // Get icon from SMDH
 | ||||
|         if (UISettings::values.game_list_icon_size.GetValue() != | ||||
|  | @ -286,7 +288,7 @@ public: | |||
| class GameListItemRegion : public GameListItem { | ||||
| public: | ||||
|     GameListItemRegion() = default; | ||||
|     explicit GameListItemRegion(const std::vector<u8>& smdh_data) { | ||||
|     explicit GameListItemRegion(std::span<const u8> smdh_data) { | ||||
|         setData(type(), TypeRole); | ||||
| 
 | ||||
|         if (!Loader::IsValidSMDH(smdh_data)) { | ||||
|  | @ -295,7 +297,7 @@ public: | |||
|         } | ||||
| 
 | ||||
|         Loader::SMDH smdh; | ||||
|         memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); | ||||
|         std::memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); | ||||
| 
 | ||||
|         setText(GetRegionFromSMDH(smdh)); | ||||
|         setData(GetRegionFromSMDH(smdh), SortRole); | ||||
|  |  | |||
|  | @ -80,7 +80,7 @@ const static std::unordered_map<VideoCore::LoadCallbackStage, const char*> progr | |||
| 
 | ||||
| static QPixmap GetQPixmapFromSMDH(std::vector<u8>& smdh_data) { | ||||
|     Loader::SMDH smdh; | ||||
|     memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); | ||||
|     std::memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); | ||||
| 
 | ||||
|     bool large = true; | ||||
|     std::vector<u16> icon_data = smdh.GetIcon(large); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue