Resource loading method and device, electronic equipment and storage medium
By creating a target resource dictionary object and saving resource files when the target application first loads the resource, the problem of reduced performance during resource loading under the WPF framework is solved, and the resource sharing efficiency is improved.
Patent Information
- Application Number
- CN202311658542.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-05
- Publication Date
- 2025-06-06
AI Technical Summary
Under the WPF framework, frequent creation of resource dictionary objects results in performance degradation and page stuttering when target applications load multiple resource files.
Create a target resource dictionary object when the target application first loads the resource and saves the target resource file to the object to avoid dynamically generating new resource dictionary objects every time the resource is loaded.
By reducing the repeated creation of resource dictionary objects, resource waste and performance reduction are avoided, and resource sharing efficiency is improved.
Smart Images

Figure CN120104203A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and specifically relates to a resource loading method, device, electronic device and storage medium. Background Art
[0002] WPF (Windows Presentation Foundation) is a user interface framework based on Windows. Under this framework, resources such as common styles are generally stored together through resource dictionary objects to achieve resource sharing.
[0003] In related applications, a target application will use multiple resource files, and these resource files will be loaded in sequence. Each time a resource file is loaded, a resource dictionary object of the ResourceDictionary class will be created. If the target application has a large amount of resource files to load, the repeated creation of resource dictionary objects will cause the performance of the application to degrade, and even cause page freezes and other phenomena. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a resource loading method, device, electronic device and storage medium, which can avoid the waste of resources and the reduction of software performance during resource loading and improve resource sharing efficiency.
[0005] In order to solve the above technical problems, this application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides a resource loading method, the method comprising: obtaining a target resource file corresponding to a target application; saving the target resource file into a target resource dictionary object, wherein the target resource dictionary object is created by the target application when loading resources for the first time; and loading resources corresponding to the target resource file by calling the target resource dictionary object.
[0007] In a second aspect, an embodiment of the present application provides a resource loading device, including a processor and a memory, wherein the memory stores a program or instruction that can be executed on the processor, and when the program or instruction is executed by the processor, the steps of the method described in the first aspect are implemented.
[0008] In a third aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0009] In an embodiment of the present application, by obtaining a target resource file corresponding to a target application; saving the target resource file into a target resource dictionary object, wherein the target resource dictionary object is created when the target application loads resources for the first time; and by calling the target resource dictionary object to load resources corresponding to the target resource file, it is possible to avoid resource waste and performance degradation caused by repeated loading of resource dictionary objects, thereby improving resource sharing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0011] Figure 1 It is a flowchart of a resource loading method provided in an embodiment of the present application.
[0012] Figure 2 It is a flowchart of another resource loading method provided in an embodiment of the present application.
[0013] Figure 3 It is a flowchart of another resource loading method provided in an embodiment of the present application.
[0014] Figure 4 It is a hardware structure diagram of a resource loading device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0015] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.
[0016] In the relevant implementation, the target application may use multiple resource files. For example, in the use of App (Application, target application), in order to achieve some effects, it may be necessary to load multiple resources, such as custom styles, form interface templates, font size settings and pictures, etc. When the target resource needs to be used, it is necessary to obtain the target resource file corresponding to the target resource, and load the target resource in the target application by running the target resource file. Each time a resource is loaded, it is necessary to access the resource dictionary (ResourceDictionary) class, and save the resource file based on the dynamic file loading method of the resource dictionary class. In the dynamic file loading method, a new resource dictionary object is created each time a resource is loaded, that is, when a resource dictionary object exists in the target application, more resource dictionary objects need to be created. As a result, new resource dictionary objects are dynamically generated when loading resources, resulting in resource waste and loss of software performance, and low resource sharing efficiency.
[0017] Figure 1 A schematic diagram of a resource loading method provided by an embodiment of the present application is shown, and the method can be executed by an electronic device. In other words, the method can be executed by software or hardware installed in the electronic device. Figure 1 As shown, the method may include the following steps.
[0018] S101: Acquire a target resource file corresponding to a target application.
[0019] In the process of using the App, in order to achieve some effects, you may need to load multiple resources, such as custom styles, form interface templates, font size settings, and pictures. When you need to use the target resource, you need to obtain the target resource file corresponding to the target resource, and load the target resource in the target application by running the target resource file.
[0020] The target resource file stores the definition of one or more related resources, such as custom styles, form interface templates, font size settings, and image resources. In the WPF framework, the target resource file can be a XAML (eXtensible Application Markup Language) file, and resources can be added to the file. In one implementation, the embodiment of the present application can be applied to an application for visual control of semiconductors.
[0021] S102: Save the target resource file into a target resource dictionary object.
[0022] The target resource dictionary object is used to store the target resource file corresponding to the target application. The target resource dictionary object is created when the target application loads resources for the first time.
[0023] The target resource dictionary object does not exist before the target application loads resources for the first time, and the target resource dictionary object is created when the target application loads resources for the first time. In one implementation, there can be one target resource dictionary object. In another implementation, there can be multiple target resource dictionary objects created in this step, but the creation timing is when the target application loads resources for the first time, that is, multiple target resource dictionary objects are created at one time, rather than each target resource dictionary object created each time the target resource file is acquired. For example, in some scenarios, the target resource file needs to be stored in two target resource dictionary objects, then two target resource dictionary objects can be created when the target application loads resources for the first time. Optionally, all target resource files acquired after the target resource dictionary object is created for the first time are saved in the target resource dictionary object, without creating the target resource dictionary object each time the target resource file is acquired. For example, when there can be one target resource dictionary object, all acquired target resource files are saved in the target resource dictionary object after the target resource dictionary object is created for the first time. For another example, in some scenarios, the target resource file needs to be stored in two target resource dictionary objects. In this case, two target resource dictionary objects can be created when the target application loads resources for the first time, and the target resource files obtained subsequently are saved in these two target resource dictionary objects. Therefore, the embodiment of the present application only creates a resource dictionary object when the resource is loaded for the first time, that is, when the resource dictionary object does not exist before, instead of dynamically generating a new resource dictionary object each time as described in the above-mentioned related art, thereby avoiding the waste of resources caused by creating target resource dictionary objects multiple times.
[0024] S103: Load resources corresponding to the target resource file by calling the target resource dictionary object.
[0025] The target resource dictionary object is called to obtain the target resource file stored in the target resource dictionary object, and the target resource file is run to load the target resource, thereby achieving the loading of the target resource in the target application.
[0026] A resource loading method provided in an embodiment of the present application, compared with related applications, generates a resource dictionary object each time a resource file is added, dynamically adds multiple resource dictionary objects, wastes resources, and causes performance loss of the application during application operation. In this embodiment of the present application, a resource dictionary object is created only when the resource is loaded for the first time, that is, when no resource dictionary object existed before, instead of dynamically generating a new resource dictionary object every time, thereby avoiding resource waste, reducing software performance loss, and improving resource sharing efficiency.
[0027] Figure 2A schematic diagram of a resource loading method provided in an embodiment of the present application is shown, and the method can be executed by an electronic device. In other words, the method can be executed by software or hardware installed in the electronic device. Figure 2 As shown, the method may include the following steps.
[0028] S201: Acquire a target resource file corresponding to a target application.
[0029] This step can be done using Figure 1 The description of step S101 of the embodiment will not be repeated here.
[0030] S202: Create a shared resource dictionary class.
[0031] The shared resource dictionary (SharedResourceDictionary) class is initially defined as a static resource loading method. In the static loading method, a target resource dictionary object is created under the shared resource dictionary class only when the target resource dictionary object does not exist in the shared resource dictionary class. Therefore, when the target application loads resources for the first time, the shared resource dictionary class is accessed. Since the target application loads resources for the first time, the target resource dictionary object corresponding to the shared resource dictionary class does not exist at this time. In this case, the target resource dictionary object corresponding to the shared resource dictionary class is created according to the static loading method of the shared resource dictionary class file. In one implementation method, the target resource dictionary object is unique, that is, only one target resource dictionary object is established for one target application, and the acquired target resource files corresponding to the target application are all saved to this one target resource dictionary object.
[0032] In the related implementation, based on the dynamic file loading method of the resource dictionary (ResourceDictionary) class, a new resource dictionary object is created each time a resource is loaded in the dynamic file loading method, that is, when the target application has a resource dictionary object, more resource dictionary objects need to be created. Compared with the related implementation, this step creates the target resource dictionary object corresponding to the shared resource dictionary class when the target resource dictionary object corresponding to the shared resource dictionary class does not exist. On the contrary, when the target resource dictionary object corresponding to the shared resource dictionary class exists, the target resource dictionary object corresponding to the shared resource dictionary class is no longer created, but the target resource file is saved to the existing target resource dictionary object. Therefore, the embodiment of the present application does not dynamically generate a new resource dictionary object every time, thereby avoiding resource waste, reducing the loss of software performance, and improving resource sharing efficiency.
[0033] S203: Save the target resource file into a target resource dictionary object.
[0034] Optionally, after the target resource dictionary object is created for the first time, all target resource files corresponding to the target application are saved in the target resource dictionary object, without creating the target resource dictionary object each time the target resource file is obtained, thereby avoiding resource waste caused by creating the target resource dictionary object multiple times.
[0035] S204: Loading resources corresponding to the target resource file by calling the target resource dictionary object.
[0036] The target resource dictionary object is called to obtain the target resource file stored in the target resource dictionary object, and the target resource file is run to load the target resource, thereby achieving the loading of the target resource in the target application.
[0037] A resource loading method provided in an embodiment of the present application, compared with related applications, generates a resource dictionary object each time a resource file is added, dynamically adds multiple resource dictionary objects, wastes resources, and causes performance loss of the application during application operation. In this embodiment of the present application, a resource dictionary object is created only when the resource is loaded for the first time, that is, when no resource dictionary object existed before, instead of dynamically generating a new resource dictionary object every time, thereby avoiding resource waste, reducing software performance loss, and improving resource sharing efficiency.
[0038] Figure 3 A schematic diagram of a resource loading method provided in an embodiment of the present application is shown, and the method can be executed by an electronic device. In other words, the method can be executed by software or hardware installed in the electronic device. Figure 3 As shown, the method may include the following steps.
[0039] S301: Create a resource file.
[0040] The resource file can be an App.xaml file.
[0041] S302: Import resources into the resource file.
[0042] Add the resources required by the target application in the App.xaml file, such as custom styles, form interface templates, font size settings, and images, etc. Thus, the target resource file corresponding to the target application is obtained.
[0043] S303: Create a shared resource dictionary class.
[0044] This step can be done using Figure 2 The description of step S202 of the embodiment will not be repeated here.
[0045] S304: Establishing a correspondence between the resource name and resource content of the target resource file.
[0046] In one implementation, after obtaining the target resource file corresponding to the target application, a correspondence between the resource name and resource content of the target resource file is established; the correspondence is used to retrieve whether there is a resource file identical to the target resource file in the target resource dictionary object.
[0047] In one implementation, the corresponding relationship is represented by a key-value data structure, wherein the key is used to represent the resource name of the target resource file, and the value is used to represent the resource content of the target resource file. In other words, the target resource file is saved in a target resource dictionary object through a key-value data structure, wherein the key is used to represent the resource name of the target resource file, and the value is used to represent the resource content of the target resource file. Optionally, the key and the value are in a one-to-one correspondence.
[0048] S305: Determine whether the same resource file exists in the target resource dictionary object.
[0049] Determine whether there is a resource file identical to the target resource file in the target resource dictionary object. Specifically, it may be searched whether there is an identical key in the corresponding relationship; if there is an identical key in the corresponding relationship, determine that there is a resource file identical to the target resource file in the target resource dictionary object, and then execute S306a.
[0050] Otherwise, if it is determined that there is no resource file identical to the target resource file in the target resource dictionary object, S306b is executed.
[0051] Optionally, determining whether the target resource file exists in the target resource dictionary object can be done recursively by searching whether the parent target resource file and the child target resource file in the target resource dictionary object have the same key. Specifically, the parent target resource file in the target resource dictionary object is searched. If the key of the parent target resource file is the same as the key of the target resource file, it is determined that there is a resource file identical to the target resource file in the target resource dictionary object. If the key of the parent target resource file is different from the key of the target resource file, the key of the child target resource file in the parent target resource file is obtained. If the key of the child target resource file is the same as the key of the target resource file, it is determined that there is a resource file identical to the target resource file in the target resource dictionary object. Conversely, if the key of the child target resource file is different from the key of the target resource file, it is determined that there is no resource file identical to the target resource file in the target resource dictionary object.
[0052] S306a: Save the target resource file into the target resource dictionary object.
[0053] Access the shared resource dictionary class; according to the file loading method of the shared resource dictionary class, if the target resource file does not exist in the target resource dictionary object, save the target resource file to the target resource dictionary object. Thus, a resource dictionary object is created only when the resource is loaded for the first time, that is, when the resource dictionary object does not exist before, instead of dynamically generating a new resource dictionary object each time as described in the above-mentioned related art, thereby avoiding resource waste caused by creating the target resource dictionary object multiple times.
[0054] S306b: Save the target resource file into the merged dictionary.
[0055] In the case that the target resource dictionary object contains a resource file identical to the target resource file, the target resource file is no longer repeatedly saved in the target resource dictionary object, thereby avoiding resource waste caused by repeated saving of resource files. In addition, the target resource file is saved in a merged dictionary (MergedDictionaries), which is used to save resource files that are repeated with those in the target resource dictionary object.
[0056] The merged dictionary may be a dictionary created before determining that there is a resource file identical to the target resource file in the target resource dictionary object, or may be an existing dictionary in the target application, that is, the existing dictionary in the target application may be used to store the duplicate resource files in this step. Optionally, in the above-mentioned related scheme, there is a dictionary for merging external resources into the local, and the dictionary may be used as the merged dictionary in this step. The merged dictionary is different from the storage location corresponding to the target resource dictionary object storing the target resource file, that is, the target resource dictionary object does not store duplicate resource files. Optionally, the merged dictionary belongs to a shared resource dictionary class, and is initially defined as a static resource loading method, in which the target resource files are loaded in chronological order. In the static loading method, a merged dictionary is created under the shared resource dictionary class only when there is no merged dictionary in the shared resource dictionary class. Thus, when the target application first determines a duplicate resource file, the shared resource dictionary class is accessed, and at this time, there is no merged dictionary corresponding to the shared resource dictionary class. In this case, a merged dictionary corresponding to the shared resource dictionary class is created according to the static loading method of the file of the shared resource dictionary class. In one implementation, the merged dictionary may be unique, that is, only one merged dictionary is established for one target application, and all the acquired duplicate resource files are saved in this merged dictionary.
[0057] In one implementation, the resource file identical to the target resource file is saved in the merged dictionary through a key-value data structure, wherein the key is used to represent the resource name of the resource file identical to the target resource file, and the value is used to represent the resource content of the resource file identical to the target resource file. This makes it convenient for users to view duplicate resource file information. Optionally, the key and value can be in a one-to-one correspondence. After loading is completed, the user can be prompted that resource information with the same name exists.
[0058] In one implementation, the embodiment of the present application may further include the following steps:
[0059] S307: Determine whether there is a file with the same key in the target resource file.
[0060] This step can recursively parse the target resource file to determine whether there is a resource file identical to the target resource file in the multiple resource files included in the target resource object or the multiple sub-resource files included in the multiple resource files. Specifically, the target resource file can include a parent target resource file and a child target resource file. In this step, the parent target resource file in the target resource dictionary object can be retrieved. If the key of the parent target resource file is the same as the key of the target resource file, it is determined that there is a resource file identical to the target resource file in the target resource dictionary object, and step S306b is executed. If the key of the parent target resource file is different from the key of the target resource file, the key of the child target resource file in the parent target resource file is obtained. If the key of the child target resource file is the same as the key of the target resource file, it is determined that there is a resource file identical to the target resource file in the target resource dictionary object, and step S306b is executed. On the contrary, if the key of the child target resource file is different from the key of the target resource file, it is determined that there is no resource file identical to the target resource file in the target resource dictionary object, and step S308 is executed. S308: Save the sub-resource file as the target resource file in the target resource dictionary object.
[0061] In this step, if the target resource dictionary object does not contain a sub-resource file of the target resource file, the sub-resource file is saved as the target resource file in the target resource dictionary object, thereby realizing the saving of all resource files.
[0062] Therefore, the embodiment of the present application creates a shared resource dictionary class; when the target application loads resources for the first time, accesses the shared resource dictionary class; and according to the file loading method of the shared resource dictionary class, when the target resource dictionary object corresponding to the shared resource dictionary class does not exist, creates the target resource dictionary object corresponding to the shared resource dictionary class, without dynamically generating a new resource dictionary object each time, thereby avoiding resource waste, reducing software performance loss, and improving resource sharing efficiency.
[0063] The embodiment of the present application establishes a correspondence between the resource name and the resource content of the target resource file, thereby facilitating determination of whether there is a resource file identical to the target resource file in the target resource dictionary object.
[0064] In the embodiment of the present application, when the target resource file does not exist in the target resource dictionary object, the target resource file is saved in the target resource dictionary object, thereby avoiding resource waste caused by repeated saving.
[0065] The embodiment of the present application saves repeated target resource files into a merged dictionary (MergedDictionaries), thereby avoiding waste of resources caused by repeated saving of resource files.
[0066] An embodiment of the present application also provides a resource loading device, including a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements each step of the resource loading method described in at least one of the above-mentioned method embodiments.
[0067] Figure 4 A schematic diagram of the hardware structure of the resource loading device provided by the embodiment of the present application is shown. Referring to the figure, at the hardware level, the resource loading device includes a processor, and optionally, an internal bus, a network interface, and a memory. Among them, the memory may include a memory, such as a high-speed random access memory (Random-Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage, etc. Of course, the resource loading device may also include hardware required for other services.
[0068] The processor, the network interface and the memory may be interconnected through an internal bus, which may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one bidirectional arrow is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0069] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0070] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a device for locating the target user at the logical level. The processor executes the program stored in the memory and is specifically used to execute: each step of the resource loading method described in at least one embodiment of the above method embodiments.
[0071] The methods disclosed in the embodiments shown in the flowcharts of the present application can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0072] The resource loading device can also execute the resource loading method described in at least one of the foregoing method embodiments, and can achieve the same technical effects as the foregoing method embodiments, which will not be described in detail here.
[0073] Of course, in addition to software implementation methods, the resource loading device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0074] An embodiment of the present application also proposes a computer-readable storage medium, which stores one or more programs. When the one or more programs are executed by an electronic device including multiple application programs, the electronic device executes to obtain a target resource file corresponding to a target application; saves the target resource file into a target resource dictionary object, which is created by the target application when loading resources for the first time; and loads resources corresponding to the target resource file by calling the target resource dictionary object.
[0075] In one implementation, before the target resource file is saved in the target resource dictionary object, a shared resource dictionary class is also created; when the target application loads resources for the first time, the shared resource dictionary class is accessed; and according to the file loading method of the shared resource dictionary class, if the target resource dictionary object corresponding to the shared resource dictionary class does not exist, the target resource dictionary object corresponding to the shared resource dictionary class is created.
[0076] In one implementation, saving the target resource file into the target resource dictionary object includes: accessing the shared resource dictionary class; and according to the file loading method of the shared resource dictionary class, saving the target resource file into the target resource dictionary object if the target resource file does not exist in the target resource dictionary object.
[0077] In one implementation, saving the target resource file into the target resource dictionary object includes: accessing the shared resource dictionary class; and according to the file loading method of the shared resource dictionary class, if there is a resource file identical to the target resource file in the target resource dictionary object, saving the target resource file into a merged dictionary, wherein the merged dictionary is used to save resource files that are repeated in the target resource dictionary object.
[0078] In one implementation, saving the target resource file into a merged dictionary includes: saving the resource file identical to the target resource file into the merged dictionary through a key-value pair data structure, wherein the key is used to represent the resource name of the resource file identical to the target resource file, and the value is used to represent the resource content of the resource file identical to the target resource file.
[0079] In one implementation, after obtaining the target resource file corresponding to the target application, a correspondence between the resource name and resource content of the target resource file is established; the correspondence is used to retrieve whether there is a resource file identical to the target resource file in the target resource dictionary object.
[0080] In one implementation, the corresponding relationship is represented by a key-value pair data structure, wherein the key is used to represent the resource name of the target resource file, and the value is used to represent the resource content of the target resource file.
[0081] In one implementation, after the correspondence between the resource name and the resource content of the target resource file is established, it is further retrieved whether the same key exists in the correspondence; if the same key exists in the correspondence, it is determined that there is a resource file identical to the target resource file in the target resource dictionary object.
[0082] And achieve the effect of at least one of the above method embodiments.
[0083] The computer-readable storage medium includes a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0084] Furthermore, an embodiment of the present application also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions, which are executed by a computer: obtaining a target resource file corresponding to a target application; saving the target resource file to a target resource dictionary object, wherein the target resource dictionary object is created by the target application when loading resources for the first time; and loading resources corresponding to the target resource file by calling the target resource dictionary object.
[0085] In one implementation, before the target resource file is saved in the target resource dictionary object, a shared resource dictionary class is also created; when the target application loads resources for the first time, the shared resource dictionary class is accessed; and according to the file loading method of the shared resource dictionary class, if the target resource dictionary object corresponding to the shared resource dictionary class does not exist, the target resource dictionary object corresponding to the shared resource dictionary class is created.
[0086] In one implementation, saving the target resource file into the target resource dictionary object includes: accessing the shared resource dictionary class; and according to the file loading method of the shared resource dictionary class, saving the target resource file into the target resource dictionary object if the target resource file does not exist in the target resource dictionary object.
[0087] In one implementation, the saving of the target resource file into the target resource dictionary object includes: accessing the shared resource dictionary class; according to the file loading method of the shared resource dictionary class, if there is a resource file identical to the target resource file in the target resource dictionary object, saving the target resource file into a merged dictionary, the merged dictionary being used to save resource files that are repeated in the target resource dictionary object. In one implementation, the saving of the target resource file into a merged dictionary includes: saving the resource file identical to the target resource file into the merged dictionary through a key-value data structure, wherein the key is used to represent the resource name of the resource file identical to the target resource file, and the value is used to represent the resource content of the resource file identical to the target resource file.
[0088] In one implementation, after obtaining the target resource file corresponding to the target application, a correspondence between the resource name and resource content of the target resource file is established; the correspondence is used to retrieve whether there is a resource file identical to the target resource file in the target resource dictionary object.
[0089] In one implementation, the corresponding relationship is represented by a key-value pair data structure, wherein the key is used to represent the resource name of the target resource file, and the value is used to represent the resource content of the target resource file.
[0090] In one implementation, after the correspondence between the resource name and the resource content of the target resource file is established, it is further retrieved whether the same key exists in the correspondence; if the same key exists in the correspondence, it is determined that there is a resource file identical to the target resource file in the target resource dictionary object.
[0091] And achieve the effect of at least one of the above method embodiments.
[0092] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0093] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0094] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0095] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0096] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A resource loading method, It is characterized in that The method comprises: Get the target resource file corresponding to the target application; Saving the target resource file into a target resource dictionary object, where the target resource dictionary object is created when the target application loads resources for the first time; By calling the target resource dictionary object, the resources corresponding to the target resource file are loaded.
2. The method according to claim 1, It is characterized in that Before saving the target resource file into the target resource dictionary object, the method further includes: Create a shared resource dictionary class; When the target application loads resources for the first time, accessing the shared resource dictionary class; According to the file loading mode of the shared resource dictionary class, when the target resource dictionary object corresponding to the shared resource dictionary class does not exist, the target resource dictionary object corresponding to the shared resource dictionary class is created.
3. The method according to claim 2, It is characterized in that The step of saving the target resource file into the target resource dictionary object comprises: Access the shared resource dictionary class; According to the file loading method of the shared resource dictionary class, when the target resource file does not exist in the target resource dictionary object, the target resource file is saved in the target resource dictionary object.
4. The method according to claim 2, It is characterized in that The step of saving the target resource file to the target resource dictionary object includes: Access the shared resource dictionary class; According to the file loading method of the shared resource dictionary class, if there is a resource file identical to the target resource file in the target resource dictionary object, the resource file identical to the target resource file is saved in a merged dictionary, and the merged dictionary is used to save the resource files repeated in the target resource dictionary object.
5. The method according to claim 4, It is characterized in that The target resource file is saved in a merge dictionary, including: The resource file identical to the target resource file is saved in the merged dictionary through a key-value pair data structure, wherein the key is used to represent the resource name of the resource file identical to the target resource file, and the value is used to represent the resource content of the resource file identical to the target resource file.
6. The method according to claim 1, It is characterized in that After obtaining the target resource file corresponding to the target application, the method further includes: A correspondence between the resource name and the resource content of the target resource file is established; the correspondence is used to retrieve whether there is a resource file identical to the target resource file in the target resource dictionary object.
7. The method according to claim 6, It is characterized in that The corresponding relationship is represented by a key-value pair data structure, wherein the key is used to represent the resource name of the target resource file, and the value is used to represent the resource content of the target resource file.
8. The method according to claim 7, It is characterized in that After establishing the correspondence between the resource name and the resource content of the target resource file, the method further includes: Check whether there is an identical key in the corresponding relationship; In the case that the same key exists in the corresponding relationship, it is determined that a resource file identical to the target resource file exists in the target resource dictionary object.
9. A resource loading device, It is characterized in that The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method according to any one of claims 1 to 8.
10. A readable storage medium, It is characterized in that The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.